test_exceptions.py
This file
Path
tests/test_exceptions.py
63 lines · 1.8 KiB · Python
Last changed by
Use `__future__.annotations` (#3068)Kar Petrosyanbefore adoption371b6e9
History of this fileTake it
The walk stopped after 200 commits: lines older than deb904d point at it.
Use `__future__.annotations` (#3068)Kar Petrosyanbefore adoption371b6e9
lines 1–2why, one step back1from __future__ import annotations2Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
line 3why, one step back3import typingremove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 4–9why, one step back45import httpcore6import pytest78import httpx9Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
lines 10–11why, one step back10if typing.TYPE_CHECKING: # pragma: no cover11 from conftest import TestServerremove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
line 12why, one step back12Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5
line 13why, one step back13remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 14–18why, one step back14def test_httpcore_all_exceptions_mapped() -> None:15 """16 All exception classes exposed by HTTPCore are properly mapped to an HTTPX-specific17 exception class.18 """Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 19–21why, one step back19 expected_mapped_httpcore_exceptions = {20 value.__name__21 for _, value in vars(httpcore).items()remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 22–24why, one step back22 if isinstance(value, type)23 and issubclass(value, Exception)24 and value is not httpcore.ConnectionNotAvailableDrop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
line 25why, one step back25 }remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
line 26why, one step back26Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 27–31why, one step back27 httpx_exceptions = {28 value.__name__29 for _, value in vars(httpx).items()30 if isinstance(value, type) and issubclass(value, Exception)31 }remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
line 32why, one step back32Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
line 33why, one step back33 unmapped_exceptions = expected_mapped_httpcore_exceptions - httpx_exceptionsremove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
line 34why, one step back34Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 35–38why, one step back35 if unmapped_exceptions: # pragma: no cover36 pytest.fail(f"Unmapped httpcore exceptions: {unmapped_exceptions}")3738Use `__future__.annotations` (#3068)Kar Petrosyanbefore adoption371b6e9
line 39why, one step back39def test_httpcore_exception_mapping(server: TestServer) -> None:remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 40–42why, one step back40 """41 HTTPCore exception mapping works as expected.42 """Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 43–45why, one step back43 impossible_port = 12345644 with pytest.raises(httpx.ConnectError):45 httpx.get(server.url.copy_with(port=impossible_port))remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
line 46why, one step back46Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15
lines 47–51why, one step back47 with pytest.raises(httpx.ReadTimeout):48 httpx.get(49 server.url.copy_with(path="/slow_response"),50 timeout=httpx.Timeout(5, read=0.01),51 )remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 52–57why, one step back525354def test_request_attribute() -> None:55 # Exception without request attribute56 exc = httpx.ReadTimeout("Read operation timed out")57 with pytest.raises(RuntimeError):Use ruff instead of flake8, autoflake and isort (#2648)Marcelo Trylesinskibefore adoptiondaec2bd
line 58why, one step back58 exc.request # noqa: B018remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d
lines 59–63why, one step back5960 # Exception with request attribute61 request = httpx.Request("GET", "https://www.example.com")62 exc = httpx.ReadTimeout("Read operation timed out", request=request)63 assert exc.request == request