Permalink
Browse files

Merge pull request #1284 from alex/patch-1

Don't try to run IPv6 tests if IPv6 is disabled at runtime
  • Loading branch information...
2 parents 3a74b5b + 52cccb0 commit ead61e0fd4f386339d78baf766f9188832ddead3 @Lukasa Lukasa committed Nov 21, 2017
Showing with 6 additions and 5 deletions.
  1. +1 −1 dummyserver/server.py
  2. +4 −3 dummyserver/testcase.py
  3. +1 −1 test/socketpair_helper.py
View
@@ -81,7 +81,7 @@ def _has_ipv6(host):
sock = socket.socket(socket.AF_INET6)
sock.bind((host, 0))
has_ipv6 = True
- except:
+ except Exception:
pass
if sock:
View
@@ -1,5 +1,4 @@
import sys
-import socket
import threading
import pytest
@@ -10,6 +9,7 @@
run_tornado_app,
run_loop_in_thread,
DEFAULT_CERTS,
+ HAS_IPV6,
)
from dummyserver.handlers import TestingApp
from dummyserver.proxy import ProxyHandler
@@ -134,7 +134,7 @@ class HTTPSDummyServerTestCase(HTTPDummyServerTestCase):
certs = DEFAULT_CERTS
-@pytest.mark.skipif(not socket.has_ipv6, reason='IPv6 not available')
+@pytest.mark.skipif(not HAS_IPV6, reason='IPv6 not available')
class IPV6HTTPSDummyServerTestCase(HTTPSDummyServerTestCase):
host = '::1'
@@ -178,11 +178,12 @@ def tearDownClass(cls):
cls.server_thread.join()
-@pytest.mark.skipif(not socket.has_ipv6, reason='IPv6 not available')
+@pytest.mark.skipif(not HAS_IPV6, reason='IPv6 not available')
class IPv6HTTPDummyServerTestCase(HTTPDummyServerTestCase):
host = '::1'
+@pytest.mark.skipif(not HAS_IPV6, reason='IPv6 not available')
class IPv6HTTPDummyProxyTestCase(HTTPDummyProxyTestCase):
http_host = 'localhost'
@@ -54,7 +54,7 @@ def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
pass
csock.setblocking(True)
ssock, _ = lsock.accept()
- except:
+ except Exception:
csock.close()
raise
finally:

0 comments on commit ead61e0

Please sign in to comment.