python-botocore/tests/unit/test_http_client_exception_mapping.py

22 lines
982 B
Python
Raw Normal View History

2021-10-04 18:33:37 +02:00
import pytest
2018-10-04 08:50:52 +02:00
from botocore import exceptions as botocore_exceptions
from botocore.vendored.requests import exceptions as requests_exceptions
from botocore.vendored.requests.packages.urllib3 import exceptions as urllib3_exceptions
2021-10-04 18:33:37 +02:00
@pytest.mark.parametrize(
"new_exception, old_exception",
(
(botocore_exceptions.ReadTimeoutError, requests_exceptions.ReadTimeout),
(botocore_exceptions.ReadTimeoutError, urllib3_exceptions.ReadTimeoutError),
(botocore_exceptions.ConnectTimeoutError, requests_exceptions.ConnectTimeout),
(botocore_exceptions.ProxyConnectionError, requests_exceptions.ProxyError),
(botocore_exceptions.SSLError, requests_exceptions.SSLError),
),
)
def test_http_client_exception_mapping(new_exception, old_exception):
2018-10-04 08:50:52 +02:00
# assert that the new exception can still be caught by the old vendored one
2021-10-04 18:33:37 +02:00
with pytest.raises(old_exception):
raise new_exception(endpoint_url=None, proxy_url=None, error=None)