Skip to content
Myr

test_queryparams.py

This file

Path

tests/client/test_queryparams.py

36 lines · 1.1 KiB · Python

Last changed by

Support Response(text=...), Response(html=...), Response(json=...) (#1297)Tom Christiebefore adoptionf3c2941

History of this file

Take it

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

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

line 1why, one step back
1import httpx

Refactor tests to use `MockTransport(<handler_function>)` (#1281)Tom Christiebefore adoptionc2afd2d

line 2why, one step back
2from tests.utils import MockTransport

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

lines 3–4why, one step back
3
4

Refactor tests to use `MockTransport(<handler_function>)` (#1281)Tom Christiebefore adoptionc2afd2d

line 5why, one step back
5def hello_world(request: httpx.Request) -> httpx.Response:

Support Response(text=...), Response(html=...), Response(json=...) (#1297)Tom Christiebefore adoptionf3c2941

line 6why, one step back
6 return httpx.Response(200, text="Hello, world")

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

lines 7–9why, one step back
7
89def test_client_queryparams():

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

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

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

lines 12–15why, one step back
12 assert client.params["a"] == "b"
131415def test_client_queryparams_string():

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

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

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

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

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

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

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

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

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

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

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

lines 23–25why, one step back
23 assert client.params["a"] == "b"
2425

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

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

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

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

Refactor tests to use `MockTransport(<handler_function>)` (#1281)Tom Christiebefore adoptionc2afd2d

lines 30–32why, one step back
30 client = httpx.Client(
31 transport=MockTransport(hello_world), params=client_queryparams32 )

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

line 33why, one step back
33 response = client.get(url, params=request_queryparams)

Tweak handling of None values in timeout type hints (#992)Florimond Mancabefore adoptionc143503

lines 34–35why, one step back
34
35 assert response.status_code == 200

Replace httpx.URL for str in tests (#1237)Eduardo Enriquezbefore adoptionaad8209

line 36why, one step back
36 assert response.url == "http://example.org/echo_queryparams?first=str&second=dict"