Use the recent support.HOSTv6 addition.

This commit is contained in:
Charles-François Natali 2013-08-31 14:40:49 +02:00
parent 79a53ea7d7
commit fcfb324e81
2 changed files with 4 additions and 8 deletions

View File

@ -587,7 +587,7 @@ def _is_ipv6_enabled():
sock = None sock = None
try: try:
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.bind(('::1', 0)) sock.bind((HOSTv6, 0))
return True return True
except OSError: except OSError:
pass pass

View File

@ -565,11 +565,7 @@ def newSocket(self):
class Inet6TestBase(InetTestBase): class Inet6TestBase(InetTestBase):
"""Base class for IPv6 socket tests.""" """Base class for IPv6 socket tests."""
# Don't use "localhost" here - it may not have an IPv6 address host = support.HOSTv6
# assigned to it by default (e.g. in /etc/hosts), and if someone
# has assigned it an IPv4-mapped address, then it's unlikely to
# work with the full IPv6 API.
host = "::1"
class UDP6TestBase(Inet6TestBase): class UDP6TestBase(Inet6TestBase):
"""Base class for UDP-over-IPv6 tests.""" """Base class for UDP-over-IPv6 tests."""
@ -1321,9 +1317,9 @@ def test_listen_backlog(self):
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.')
def test_flowinfo(self): def test_flowinfo(self):
self.assertRaises(OverflowError, socket.getnameinfo, self.assertRaises(OverflowError, socket.getnameinfo,
('::1',0, 0xffffffff), 0) (support.HOSTv6, 0, 0xffffffff), 0)
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s: with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
self.assertRaises(OverflowError, s.bind, ('::1', 0, -10)) self.assertRaises(OverflowError, s.bind, (support.HOSTv6, 0, -10))
@unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.')