From 4522f15c890e89f7a1ace243b2c1cbbaf76c5671 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 20 Oct 2017 13:37:26 +0200 Subject: [PATCH] skip ipv6 tests on sudo-enabled travis builds --- test/conftest.py | 16 ++++++++++++++++ test/mitmproxy/net/test_tcp.py | 2 ++ 2 files changed, 18 insertions(+) diff --git a/test/conftest.py b/test/conftest.py index b0842bc3e..27918cf95 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,6 @@ import os +import socket + import pytest pytest_plugins = ('test.full_coverage_plugin',) @@ -17,3 +19,17 @@ skip_appveyor = pytest.mark.skipif( "APPVEYOR" in os.environ, reason='Skipping due to Appveyor' ) + +try: + s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + s.bind(("::1", 0)) + s.close() +except OSError: + no_ipv6 = True +else: + no_ipv6 = False + +skip_no_ipv6 = pytest.mark.skipif( + no_ipv6, + reason='Host has no IPv6 support' +) diff --git a/test/mitmproxy/net/test_tcp.py b/test/mitmproxy/net/test_tcp.py index 9d521533f..3e27929d2 100644 --- a/test/mitmproxy/net/test_tcp.py +++ b/test/mitmproxy/net/test_tcp.py @@ -12,6 +12,7 @@ from mitmproxy import certs from mitmproxy.net import tcp from mitmproxy import exceptions from mitmproxy.test import tutils +from ...conftest import skip_no_ipv6 from . import tservers @@ -112,6 +113,7 @@ class TestServerBind(tservers.ServerTestBase): pass +@skip_no_ipv6 class TestServerIPv6(tservers.ServerTestBase): handler = EchoHandler addr = ("::1", 0)