All exception classes exposed by HTTPCore are properly mapped to an HTTPX-specific exception class.
()
| 12 | |
| 13 | |
| 14 | def test_httpcore_all_exceptions_mapped() -> None: |
| 15 | """ |
| 16 | All exception classes exposed by HTTPCore are properly mapped to an HTTPX-specific |
| 17 | exception class. |
| 18 | """ |
| 19 | expected_mapped_httpcore_exceptions = { |
| 20 | value.__name__ |
| 21 | for _, value in vars(httpcore).items() |
| 22 | if isinstance(value, type) |
| 23 | and issubclass(value, Exception) |
| 24 | and value is not httpcore.ConnectionNotAvailable |
| 25 | } |
| 26 | |
| 27 | httpx_exceptions = { |
| 28 | value.__name__ |
| 29 | for _, value in vars(httpx).items() |
| 30 | if isinstance(value, type) and issubclass(value, Exception) |
| 31 | } |
| 32 | |
| 33 | unmapped_exceptions = expected_mapped_httpcore_exceptions - httpx_exceptions |
| 34 | |
| 35 | if unmapped_exceptions: # pragma: no cover |
| 36 | pytest.fail(f"Unmapped httpcore exceptions: {unmapped_exceptions}") |
| 37 | |
| 38 | |
| 39 | def test_httpcore_exception_mapping(server: TestServer) -> None: |