File: test_http_client_exception_mapping.py

package info (click to toggle)
python-botocore 1.40.72%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 128,088 kB
  • sloc: python: 76,667; xml: 14,037; javascript: 181; makefile: 157
file content (35 lines) | stat: -rw-r--r-- 1,095 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest

from botocore import exceptions as botocore_exceptions
from requests import exceptions as requests_exceptions
from requests.packages.urllib3 import (
    exceptions as urllib3_exceptions,
)


@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):
    # assert that the new exception can still be caught by the old vendored one
    with pytest.raises(old_exception):
        raise new_exception(endpoint_url=None, proxy_url=None, error=None)