From 04d65197c72930fbc2857e7384418d6f045f7aa0 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Tue, 18 Aug 2020 19:45:33 -0700 Subject: On win32, skip valid IPv6 addresses that socket.inet_pton() erroneously thinks are invalid. --- tests/test_address.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/test_address.py b/tests/test_address.py index 98150f2..1ee7022 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -248,13 +248,20 @@ class IPv6Tests(unittest.TestCase): "::0:a:b:c:d:e:f", "a:b:c:d:e:f:0::", ) - if sys.platform == 'win32': - for s in valid: - try: - socket.inet_pton(socket.AF_INET6, s) - except Exception: - print('win32 rejects:', s) + + win32_invalid = { + "::2:3:4:5:6:7:8", + "::2222:3333:4444:5555:6666:7777:8888", + "::2222:3333:4444:5555:6666:123.123.123.123", + "::0:0:0:0:0:0:0", + "::0:a:b:c:d:e:f", + } + for s in valid: + if sys.platform == 'win32' and s in win32_invalid: + # socket.inet_pton() on win32 rejects some valid (as + # far as we can tell) IPv6 addresses. Skip them. + continue self.assertEqual(dns.ipv6.inet_aton(s), socket.inet_pton(socket.AF_INET6, s)) -- cgit v1.2.1