test_properties.py
This file
Path
tests/client/test_properties.py
60 lines · 1.9 KiB · Python
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 2e4b308 point at it.
Make the MockTransport example more robust/correct (#1621)Vytautas Liuoliabefore adoption2e4b308
lines 1–60why, one step back1import httpx234def test_client_base_url():5 client = httpx.Client()6 client.base_url = "https://www.example.org/" # type: ignore7 assert isinstance(client.base_url, httpx.URL)8 assert client.base_url == "https://www.example.org/"91011def test_client_base_url_without_trailing_slash():12 client = httpx.Client()13 client.base_url = "https://www.example.org/path" # type: ignore14 assert isinstance(client.base_url, httpx.URL)15 assert client.base_url == "https://www.example.org/path/"161718def test_client_base_url_with_trailing_slash():19 client = httpx.Client()20 client.base_url = "https://www.example.org/path/" # type: ignore21 assert isinstance(client.base_url, httpx.URL)22 assert client.base_url == "https://www.example.org/path/"232425def test_client_headers():26 client = httpx.Client()27 client.headers = {"a": "b"} # type: ignore28 assert isinstance(client.headers, httpx.Headers)29 assert client.headers["A"] == "b"303132def test_client_cookies():33 client = httpx.Client()34 client.cookies = {"a": "b"} # type: ignore35 assert isinstance(client.cookies, httpx.Cookies)36 mycookies = list(client.cookies.jar)37 assert len(mycookies) == 138 assert mycookies[0].name == "a" and mycookies[0].value == "b"394041def test_client_timeout():42 expected_timeout = 12.043 client = httpx.Client()4445 client.timeout = expected_timeout # type: ignore4647 assert isinstance(client.timeout, httpx.Timeout)48 assert client.timeout.connect == expected_timeout49 assert client.timeout.read == expected_timeout50 assert client.timeout.write == expected_timeout51 assert client.timeout.pool == expected_timeout525354def test_client_event_hooks():55 def on_request(request):56 pass # pragma: nocover5758 client = httpx.Client()59 client.event_hooks = {"request": [on_request]}60 assert client.event_hooks == {"request": [on_request], "response": []}