[Git][NTPsec/ntpsec][master] Make sure IPv6 tests only run if python has IPv6 support enabled

Matt Selsky gitlab at mg.gitlab.com
Sun Jul 29 15:03:15 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
0c036bae by Matt Selsky at 2018-07-29T14:32:06Z
Make sure IPv6 tests only run if python has IPv6 support enabled

$ python build/main/tests/pylib/ntp/packet.py
....................................E.....................
======================================================================
ERROR: test_MRUEntry (__main__.TestMisc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "build/main/tests/pylib/test_packet.py", line 563, in test_MRUEntry
    self.assertEqual(cls.sortaddr(),
  File "/home/selsky/ntpsec/build/main/tests/pylib/ntp/packet.py", line 725, in sortaddr
    return socket.inet_pton(socket.AF_INET6, addr)
error: can't use AF_INET6, IPv6 is disabled

----------------------------------------------------------------------
Ran 58 tests in 0.015s

FAILED (errors=1)

Reported in https://bugs.gentoo.org/659534

- - - - -


1 changed file:

- tests/pylib/test_packet.py


Changes:

=====================================
tests/pylib/test_packet.py
=====================================
@@ -558,16 +558,18 @@ class TestMisc(unittest.TestCase):
         cls.first = "0x00000100.00000000"
         cls.ct = 4
         self.assertEqual(cls.avgint(), 64)
-        # Test sortaddr, ipv6
-        cls.addr = "[11:22:33::44:55]:42"
-        self.assertEqual(cls.sortaddr(),
-                         polybytes("\x00\x11\x00\x22\x00\x33\x00\x00"
-                                   "\x00\x00\x00\x00\x00\x44\x00\x55"))
-        # Test sortaddr, ipv6, local
-        cls.addr = "[11:22:33::44:55%8]:42"
-        self.assertEqual(cls.sortaddr(),
-                         polybytes("\x00\x11\x00\x22\x00\x33\x00\x00"
-                                   "\x00\x00\x00\x00\x00\x44\x00\x55"))
+        if socket.has_ipv6:
+            # Test sortaddr, ipv6
+            cls.addr = "[11:22:33::44:55]:42"
+            self.assertEqual(cls.sortaddr(),
+                             polybytes("\x00\x11\x00\x22\x00\x33\x00\x00"
+                                       "\x00\x00\x00\x00\x00\x44\x00\x55"))
+            # Test sortaddr, ipv6, local
+            cls.addr = "[11:22:33::44:55%8]:42"
+            self.assertEqual(cls.sortaddr(),
+                             polybytes("\x00\x11\x00\x22\x00\x33\x00\x00"
+                                       "\x00\x00\x00\x00\x00\x44\x00\x55"))
+
         # Test sortaddr, ipv4
         cls.addr = "11.22.33.44:23"
         self.assertEqual(cls.sortaddr(),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/0c036baedc1757c12fbffda72fcf45744bdd4f51

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/0c036baedc1757c12fbffda72fcf45744bdd4f51
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180729/a18c50a4/attachment-0001.html>


More information about the vc mailing list