# HG changeset patch # User Augie Fackler # Date 1508959834 14400 # Node ID 1122a90e329abca65c3ae3f3697f4619b1df1dca # Parent f73cc01a8167b70b2c3ac650f76d1f9c75537c89 test_push_command: deal with gethostname() sometimes returning bad hostnames diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -145,7 +145,14 @@ class PushTests(test_util.TestBase): # support and expect IPv6. As a workaround, resolve the hostname # within the test harness with `getaddrinfo(3)` to ensure that the # client and server both use the same IPv4 or IPv6 address. - addrinfo = socket.getaddrinfo(self.host, self.port) + try: + addrinfo = socket.getaddrinfo(self.host, self.port) + except socket.gaierror as e: + # gethostname() can give a hostname that doesn't + # resolve. Seems bad, but let's fall back to `localhost` in + # that case and hope for the best. + self.host = 'localhost' + addrinfo = socket.getaddrinfo(self.host, self.port) # On macOS svn seems to have issues with IPv6 at least some of # the time, so try and bias towards IPv4. This works because # AF_INET is less than AF_INET6 on all platforms I've