tests: IPv6 issue
This commit is contained in:
parent
250c808353
commit
3537960914
2 changed files with 2 additions and 23 deletions
|
@ -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):
|
||||
|
|
|
@ -3,3 +3,4 @@ docker==7.1.0
|
|||
packaging==24.2
|
||||
pytest==8.3.4
|
||||
requests==2.32.3
|
||||
urllib3==2.3.0
|
Loading…
Reference in a new issue