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:
CI_TIMEOUT = 10
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,), {})):
__timeout__ = LOCAL_TIMEOUT if not RUNNING_ON_CI else CI_TIMEOUT
switch_expected = 'default'
......
......@@ -86,8 +86,11 @@ class TestCase(greentest.TestCase):
def get_server_host_port_family(self):
server_host = self.server.server_host
if not server_host or server_host == '::':
server_host = 'localhost'
if not server_host:
server_host = greentest.DEFAULT_LOCAL_HOST_ADDR
elif server_host == '::':
server_host = greentest.DEFAULT_LOCAL_HOST_ADDR6
try:
family = self.server.socket.family
except AttributeError:
......
......@@ -267,7 +267,7 @@ class TestTCP(greentest.TestCase):
# Issue 841
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
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)
s.close()
......@@ -283,7 +283,7 @@ class TestTCP(greentest.TestCase):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(False)
with self.assertRaises(OverflowError):
s.connect_ex(('localhost', 65539))
s.connect_ex((greentest.DEFAULT_LOCAL_HOST_ADDR, 65539))
s.close()
@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