Tests: generalize IPv6 detection
This commit is contained in:
parent
7760f4edf0
commit
94bb4fbdae
@ -108,16 +108,18 @@ class TestBaseServerRequests:
|
|||||||
assert status == 302
|
assert status == 302
|
||||||
|
|
||||||
def test_ipv6(self):
|
def test_ipv6(self):
|
||||||
if (not server.HAS_IPV6 or os.environ.get("TRAVIS_OS_NAME") == "osx" or
|
if not server.HAS_IPV6:
|
||||||
os.environ.get("TRAVIS_SUDO") == "true"):
|
pytest.skip("IPv6 not supported")
|
||||||
pytest.skip("IPv6 not support")
|
|
||||||
if os.name == "nt" and server.EAI_ADDRFAMILY is None:
|
if os.name == "nt" and server.EAI_ADDRFAMILY is None:
|
||||||
# HACK: incomplete errno conversion in WINE
|
# HACK: incomplete errno conversion in WINE
|
||||||
server.EAI_ADDRFAMILY = -9
|
server.EAI_ADDRFAMILY = -9
|
||||||
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
||||||
sock.setsockopt(server.IPPROTO_IPV6, server.IPV6_V6ONLY, 1)
|
sock.setsockopt(server.IPPROTO_IPV6, server.IPV6_V6ONLY, 1)
|
||||||
# Find available port
|
try:
|
||||||
sock.bind(("::1", 0))
|
# Find available port
|
||||||
|
sock.bind(("::1", 0))
|
||||||
|
except OSError:
|
||||||
|
pytest.skip("IPv6 not supported")
|
||||||
self.sockname = sock.getsockname()[:2]
|
self.sockname = sock.getsockname()[:2]
|
||||||
self.configuration["server"]["hosts"] = "[%s]:%d" % self.sockname
|
self.configuration["server"]["hosts"] = "[%s]:%d" % self.sockname
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user