Skip to content
Myr

test_queryparams.py

This file

Path

tests/client/test_queryparams.py

51 lines · 1.6 KiB · Python

Last changed by

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

History of this file

Take it

The walk stopped after 200 commits: lines older than b234203 point at it.

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 1why, one step back
1import typing

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

line 2why, one step back
2

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 3why, one step back
3import httpcore

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

line 4why, one step back
4

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 5why, one step back
5import httpx

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 6why, one step back
6from httpx._content_streams import ContentStream, JSONStream

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 7–8why, one step back
7
8

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 9–10why, one step back
9class MockTransport(httpcore.SyncHTTPTransport):
10 def request(

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

line 11why, one step back
11 self,

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 12why, one step back
12 method: bytes,

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

lines 13–14why, one step back
13 url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],
14 headers: typing.List[typing.Tuple[bytes, bytes]] = None,

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 15why, one step back
15 stream: httpcore.SyncByteStream = None,

Update to httpcore 0.10 (#1126)Tom Christiebefore adoption876e722

line 16why, one step back
16 timeout: typing.Mapping[str, typing.Optional[float]] = None,

Httpcore interface (#804)Tom Christiebefore adoption3046e92

lines 17–20why, one step back
17 ) -> typing.Tuple[
18 bytes, int, bytes, typing.List[typing.Tuple[bytes, bytes]], ContentStream19 ]:20 body = JSONStream({"ok": "ok"})

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 21why, one step back
21 return b"HTTP/1.1", 200, b"OK", [], body

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 22–24why, one step back
22
2324def test_client_queryparams():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 25–26why, one step back
25 client = httpx.Client(params={"a": "b"})
26 assert isinstance(client.params, httpx.QueryParams)

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 27–30why, one step back
27 assert client.params["a"] == "b"
282930def test_client_queryparams_string():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 31–32why, one step back
31 client = httpx.Client(params="a=b")
32 assert isinstance(client.params, httpx.QueryParams)

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 33–34why, one step back
33 assert client.params["a"] == "b"
34

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 35why, one step back
35 client = httpx.Client()

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 36why, one step back
36 client.params = "a=b" # type: ignore

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 37why, one step back
37 assert isinstance(client.params, httpx.QueryParams)

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 38–40why, one step back
38 assert client.params["a"] == "b"
3940

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 41why, one step back
41def test_client_queryparams_echo():

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 42–44why, one step back
42 url = "http://example.org/echo_queryparams"
43 client_queryparams = "first=str"44 request_queryparams = {"second": "dict"}

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 45–46why, one step back
45 client = httpx.Client(transport=MockTransport(), params=client_queryparams)
46 response = client.get(url, params=request_queryparams)

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 47–48why, one step back
47
48 assert response.status_code == 200

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 49why, one step back
49 assert response.url == httpx.URL(

Detect credentials in proxy URLs and create Proxy-authorization header (#780)Yeray Diaz Diazbefore adoptionb234203

lines 50–51why, one step back
50 "http://example.org/echo_queryparams?first=str&second=dict"
51 )