Commit 7b8de66f authored by Jason Madden's avatar Jason Madden

Try to fix the travis server errors.

parent 98c2c15f
...@@ -369,6 +369,18 @@ if PY3 and PYPY: ...@@ -369,6 +369,18 @@ if PY3 and PYPY:
CI_TIMEOUT = 10 CI_TIMEOUT = 10
LOCAL_TIMEOUT = 1 LOCAL_TIMEOUT = 1
DEFAULT_LOCAL_HOST_ADDR = 'localhost'
DEFAULT_LOCAL_HOST_ADDR6 = DEFAULT_LOCAL_HOST_ADDR
if RUNNING_ON_TRAVIS:
# As of November 2017 (probably Sept or Oct), after a
# Travis upgrade, using "localhost" no longer works,
# producing 'OSError: [Errno 99] Cannot assign
# requested address'. This is apparently something to do with
# docker containers. Sigh.
DEFAULT_LOCAL_HOST_ADDR = '127.0.0.1'
DEFAULT_LOCAL_HOST_ADDR6 = '::1'
class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})): class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})):
__timeout__ = LOCAL_TIMEOUT if not RUNNING_ON_CI else CI_TIMEOUT __timeout__ = LOCAL_TIMEOUT if not RUNNING_ON_CI else CI_TIMEOUT
switch_expected = 'default' switch_expected = 'default'
......
...@@ -86,8 +86,11 @@ class TestCase(greentest.TestCase): ...@@ -86,8 +86,11 @@ class TestCase(greentest.TestCase):
def get_server_host_port_family(self): def get_server_host_port_family(self):
server_host = self.server.server_host server_host = self.server.server_host
if not server_host or server_host == '::': if not server_host:
server_host = 'localhost' server_host = greentest.DEFAULT_LOCAL_HOST_ADDR
elif server_host == '::':
server_host = greentest.DEFAULT_LOCAL_HOST_ADDR6
try: try:
family = self.server.socket.family family = self.server.socket.family
except AttributeError: except AttributeError:
......
...@@ -267,7 +267,7 @@ class TestTCP(greentest.TestCase): ...@@ -267,7 +267,7 @@ class TestTCP(greentest.TestCase):
# Issue 841 # Issue 841
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(False) s.setblocking(False)
ret = s.connect_ex(('localhost', get_port())) ret = s.connect_ex((greentest.DEFAULT_LOCAL_HOST_ADDR, get_port()))
self.assertIsInstance(ret, errno_types) self.assertIsInstance(ret, errno_types)
s.close() s.close()
...@@ -283,7 +283,7 @@ class TestTCP(greentest.TestCase): ...@@ -283,7 +283,7 @@ class TestTCP(greentest.TestCase):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(False) s.setblocking(False)
with self.assertRaises(OverflowError): with self.assertRaises(OverflowError):
s.connect_ex(('localhost', 65539)) s.connect_ex((greentest.DEFAULT_LOCAL_HOST_ADDR, 65539))
s.close() s.close()
@unittest.skipUnless(hasattr(socket, 'SOCK_CLOEXEC'), @unittest.skipUnless(hasattr(socket, 'SOCK_CLOEXEC'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment