bpo-37199: Fix test failures when IPv6 is unavailable or disabled (#14480)

This commit is contained in:
Zackery Spytz 2019-06-30 09:24:43 -06:00 committed by Andrew Svetlov
parent 0d671c04c3
commit c2cda638d6
5 changed files with 21 additions and 4 deletions

View file

@ -4964,8 +4964,15 @@ class NetworkConnectionNoServer(unittest.TestCase):
# Issue #9792: create_connection() should not recast timeout errors
# as generic socket errors.
with self.mocked_socket_module():
with self.assertRaises(socket.timeout):
try:
socket.create_connection((HOST, 1234))
except socket.timeout:
pass
except OSError as exc:
if support.IPV6_ENABLED or exc.errno != errno.EAFNOSUPPORT:
raise
else:
self.fail('socket.timeout not raised')
class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):