test_queryparams.py
This file
Path
tests/client/test_queryparams.py
53 lines · 1.7 KiB · Python
Last changed by
Type check tests (#1054)Florimond Mancabefore adoption0296c2b
History of this fileTake it
The walk stopped after 200 commits: lines older than 22663bc point at it.
Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 1why, one step back1import typingUpdate link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
line 2why, one step back2Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 3why, one step back3import httpcoreUpdate link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
lines 4–5why, one step back4import pytest5Type check tests (#1054)Florimond Mancabefore adoption0296c2b
line 6why, one step back6from httpx import URL, AsyncClient, QueryParamsHttpcore interface (#804)Tom Christiebefore adoption3046e92
line 7why, one step back7from httpx._content_streams import ContentStream, JSONStreamUpdate link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
lines 8–9why, one step back89Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100
line 10why, one step back10class MockTransport(httpcore.AsyncHTTPTransport):Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 11why, one step back11 async def request(Update link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
line 12why, one step back12 self,Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 13why, one step back13 method: bytes,Type check tests (#1054)Florimond Mancabefore adoption0296c2b
lines 14–16why, one step back14 url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],15 headers: typing.List[typing.Tuple[bytes, bytes]] = None,16 stream: httpcore.AsyncByteStream = None,Httpcore interface (#804)Tom Christiebefore adoption3046e92
lines 17–21why, one step back17 timeout: typing.Dict[str, typing.Optional[float]] = None,18 ) -> typing.Tuple[19 bytes, int, bytes, typing.List[typing.Tuple[bytes, bytes]], ContentStream20 ]:21 body = JSONStream({"ok": "ok"})Type check tests (#1054)Florimond Mancabefore adoption0296c2b
line 22why, one step back22 return b"HTTP/1.1", 200, b"OK", [], bodyUpdate link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
lines 23–36why, one step back232425def test_client_queryparams():26 client = AsyncClient(params={"a": "b"})27 assert isinstance(client.params, QueryParams)28 assert client.params["a"] == "b"293031def test_client_queryparams_string():32 client = AsyncClient(params="a=b")33 assert isinstance(client.params, QueryParams)34 assert client.params["a"] == "b"3536 client = AsyncClient()Type check tests (#1054)Florimond Mancabefore adoption0296c2b
line 37why, one step back37 client.params = "a=b" # type: ignoreUpdate link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
lines 38–46why, one step back38 assert isinstance(client.params, QueryParams)39 assert client.params["a"] == "b"404142@pytest.mark.asyncio43async def test_client_queryparams_echo():44 url = "http://example.org/echo_queryparams"45 client_queryparams = "first=str"46 request_queryparams = {"second": "dict"}Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100
line 47why, one step back47 client = AsyncClient(transport=MockTransport(), params=client_queryparams)Update link to timeout fine tuning in quickstart (#696)David Larletbefore adoption22663bc
lines 48–53why, one step back48 response = await client.get(url, params=request_queryparams)4950 assert response.status_code == 20051 assert response.url == URL(52 "http://example.org/echo_queryparams?first=str&second=dict"53 )