Travis doesn't support IPv6 on osx and linux with sudo

This commit is contained in:
Unrud 2018-09-06 10:50:55 +02:00
parent 8fe2d987e0
commit 7760f4edf0

View File

@ -26,7 +26,6 @@ import ssl
import tempfile import tempfile
import threading import threading
import time import time
import warnings
from urllib import request from urllib import request
from urllib.error import HTTPError, URLError from urllib.error import HTTPError, URLError
@ -109,10 +108,11 @@ class TestBaseServerRequests:
assert status == 302 assert status == 302
def test_ipv6(self): def test_ipv6(self):
if not server.HAS_IPV6: if (not server.HAS_IPV6 or os.environ.get("TRAVIS_OS_NAME") == "osx" or
os.environ.get("TRAVIS_SUDO") == "true"):
pytest.skip("IPv6 not support") pytest.skip("IPv6 not support")
if os.name == "nt" and os.environ.get("WINE_PYTHON"): if os.name == "nt" and server.EAI_ADDRFAMILY is None:
warnings.warn("WORKAROUND: 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)