Skip to content
Myr

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 file

Take 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 back
1from __future__ import annotations
2

Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5

line 3why, one step back
3import typing

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

lines 4–9why, one step back
4
5import httpcore6import pytest78import httpx9

Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5

lines 10–11why, one step back
10if typing.TYPE_CHECKING: # pragma: no cover
11 from conftest import TestServer

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

line 12why, one step back
12

Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5

line 13why, one step back
13

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

lines 14–18why, one step back
14def 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 back
19 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 back
22 if isinstance(value, type)
23 and issubclass(value, Exception)24 and value is not httpcore.ConnectionNotAvailable

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

line 25why, one step back
25 }

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

line 26why, one step back
26

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

lines 27–31why, one step back
27 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 back
32

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

line 33why, one step back
33 unmapped_exceptions = expected_mapped_httpcore_exceptions - httpx_exceptions

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

line 34why, one step back
34

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

lines 35–38why, one step back
35 if unmapped_exceptions: # pragma: no cover
36 pytest.fail(f"Unmapped httpcore exceptions: {unmapped_exceptions}")3738

Use `__future__.annotations` (#3068)Kar Petrosyanbefore adoption371b6e9

line 39why, one step back
39def 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 back
40 """
41 HTTPCore exception mapping works as expected.42 """

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

lines 43–45why, one step back
43 impossible_port = 123456
44 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 back
46

Drop private imports from test_exceptions.py (#2571)Florimond Mancabefore adoption7488b15

lines 47–51why, one step back
47 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 back
52
5354def 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 back
58 exc.request # noqa: B018

remove `chunk_size` from api docs for `iter_lines` variants (#2464)Simon Kbefore adoptiondeb904d

lines 59–63why, one step back
59
60 # 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