test_exceptions.py
This file
Path
tests/test_exceptions.py
61 lines · 1.8 KiB · Python
Last changed by
Use ruff instead of flake8, autoflake and isort (#2648)Marcelo Trylesinskibefore adoptiondaec2bd
History of this fileTake it
The walk stopped after 200 commits: lines older than 781076c point at it.
Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
line 1why, one step back1import typingFix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 2–7why, one step back23import httpcore4import pytest56import httpx7Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
lines 8–9why, one step back8if typing.TYPE_CHECKING: # pragma: no cover9 from conftest import TestServerFix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
line 10why, one step back10Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
line 11why, one step back11Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 12–16why, one step back12def test_httpcore_all_exceptions_mapped() -> None:13 """14 All exception classes exposed by HTTPCore are properly mapped to an HTTPX-specific15 exception class.16 """Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 17–19why, one step back17 expected_mapped_httpcore_exceptions = {18 value.__name__19 for _, value in vars(httpcore).items()Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 20–22why, one step back20 if isinstance(value, type)21 and issubclass(value, Exception)22 and value is not httpcore.ConnectionNotAvailableDrop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
line 23why, one step back23 }Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
line 24why, one step back24Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 25–29why, one step back25 httpx_exceptions = {26 value.__name__27 for _, value in vars(httpx).items()28 if isinstance(value, type) and issubclass(value, Exception)29 }Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
line 30why, one step back30Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
line 31why, one step back31 unmapped_exceptions = expected_mapped_httpcore_exceptions - httpx_exceptionsFix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
line 32why, one step back32Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 33–36why, one step back33 if unmapped_exceptions: # pragma: no cover34 pytest.fail(f"Unmapped httpcore exceptions: {unmapped_exceptions}")3536Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
line 37why, one step back37def test_httpcore_exception_mapping(server: "TestServer") -> None:Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 38–40why, one step back38 """39 HTTPCore exception mapping works as expected.40 """Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 41–43why, one step back41 impossible_port = 12345642 with pytest.raises(httpx.ConnectError):43 httpx.get(server.url.copy_with(port=impossible_port))Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
line 44why, one step back44Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 45–49why, one step back45 with pytest.raises(httpx.ReadTimeout):46 httpx.get(47 server.url.copy_with(path="/slow_response"),48 timeout=httpx.Timeout(5, read=0.01),49 )Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 50–55why, one step back505152def test_request_attribute() -> None:53 # Exception without request attribute54 exc = httpx.ReadTimeout("Read operation timed out")55 with pytest.raises(RuntimeError):Use ruff instead of flake8, autoflake and isort (#2648)Marcelo Trylesinskibefore adoptiondaec2bd
line 56why, one step back56 exc.request # noqa: B018Fix raise_for_status exception docs (#2159)Johannesbefore adoption781076c
lines 57–61why, one step back5758 # Exception with request attribute59 request = httpx.Request("GET", "https://www.example.com")60 exc = httpx.ReadTimeout("Read operation timed out", request=request)61 assert exc.request == request