Skip to content
Myr

test_queryparams.py

This file

Path

tests/client/test_queryparams.py

35 lines · 1.1 KiB · Python

Last changed by

Add `httpx.MockTransport()` (#1401)Tom Christiebefore adoption9c7c2ac

History of this file

Take it

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

Minor decoder refactoring. (#1276)Tom Christiebefore adoption6006721

lines 1–3why, one step back
1import httpx
23

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

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

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

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

Minor decoder refactoring. (#1276)Tom Christiebefore adoption6006721

lines 6–28why, one step back
6
78def test_client_queryparams():9 client = httpx.Client(params={"a": "b"})10 assert isinstance(client.params, httpx.QueryParams)11 assert client.params["a"] == "b"121314def test_client_queryparams_string():15 client = httpx.Client(params="a=b")16 assert isinstance(client.params, httpx.QueryParams)17 assert client.params["a"] == "b"1819 client = httpx.Client()20 client.params = "a=b" # type: ignore21 assert isinstance(client.params, httpx.QueryParams)22 assert client.params["a"] == "b"232425def test_client_queryparams_echo():26 url = "http://example.org/echo_queryparams"27 client_queryparams = "first=str"28 request_queryparams = {"second": "dict"}

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

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

Add `httpx.MockTransport()` (#1401)Tom Christiebefore adoption9c7c2ac

line 30why, one step back
30 transport=httpx.MockTransport(hello_world), params=client_queryparams

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

line 31why, one step back
31 )

Minor decoder refactoring. (#1276)Tom Christiebefore adoption6006721

lines 32–35why, one step back
32 response = client.get(url, params=request_queryparams)
3334 assert response.status_code == 20035 assert response.url == "http://example.org/echo_queryparams?first=str&second=dict"