diff --git a/test/conftest.py b/test/conftest.py index 0840f1a..fb8d695 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -18,6 +18,7 @@ import requests from docker.models.containers import Container from docker.models.networks import Network from packaging.version import Version +from urllib3.util.connection import HAS_IPV6 logging.basicConfig(level=logging.INFO) logging.getLogger('backoff').setLevel(logging.INFO) @@ -42,29 +43,6 @@ test_container = 'nginx-proxy-pytest' # ############################################################################### -def _has_ipv6(host: str) -> bool: - """Returns True if the system can bind an IPv6 address.""" - sock = None - has_ipv6 = False - - if socket.has_ipv6: - # has_ipv6 returns true if cPython was compiled with IPv6 support. - # It does not tell us if the system has IPv6 support enabled. To - # determine that we must bind to an IPv6 address. - # https://github.com/urllib3/urllib3/pull/611 - # https://bugs.python.org/issue658327 - try: - sock = socket.socket(socket.AF_INET6) - sock.bind((host, 0)) - has_ipv6 = True - except Exception: - pass - - if sock: - sock.close() - return has_ipv6 - -HAS_IPV6 = _has_ipv6("::1") @contextlib.contextmanager def ipv6(force_ipv6=True): diff --git a/test/requirements/python-requirements.txt b/test/requirements/python-requirements.txt index fa176ae..fb8e405 100644 --- a/test/requirements/python-requirements.txt +++ b/test/requirements/python-requirements.txt @@ -3,3 +3,4 @@ docker==7.1.0 packaging==24.2 pytest==8.3.4 requests==2.32.3 +urllib3==2.3.0 \ No newline at end of file