restore EAI_ADDRFAMILY after test

This commit is contained in:
Unrud 2018-09-09 14:58:42 +02:00
parent e4ee569bd2
commit 95d8c273c4

View File

@ -110,9 +110,6 @@ class TestBaseServerRequests:
def test_ipv6(self): def test_ipv6(self):
if not server.HAS_IPV6: if not server.HAS_IPV6:
pytest.skip("IPv6 not supported") pytest.skip("IPv6 not supported")
if os.name == "nt" and server.EAI_ADDRFAMILY is None:
# HACK: incomplete errno conversion in WINE
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)
try: try:
@ -122,6 +119,13 @@ class TestBaseServerRequests:
pytest.skip("IPv6 not supported") 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
savedEaiAddrfamily = server.EAI_ADDRFAMILY
if os.name == "nt" and server.EAI_ADDRFAMILY is None:
# HACK: incomplete errno conversion in WINE
server.EAI_ADDRFAMILY = -9
try:
self.thread.start() self.thread.start()
status, _, _ = self.request("GET", "/") status, _, _ = self.request("GET", "/")
finally:
server.EAI_ADDRFAMILY = savedEaiAddrfamily
assert status == 302 assert status == 302