]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130607: Extend and cleanup IPv6 tests (GH-121518)
authorIlya Bazhenov <31971067+bazhil@users.noreply.github.com>
Fri, 28 Feb 2025 10:31:30 +0000 (13:31 +0300)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2025 10:31:30 +0000 (11:31 +0100)
Extend IPv6 tests and made little syntax refactoring

Lib/test/test_ipaddress.py

index b1ac2b94f41b38b64b8ac88e6b6c0aab9cdc114f..d04012d1afd5408f8faa8380f1d6320de9ab630c 100644 (file)
@@ -894,8 +894,8 @@ class ComparisonTests(unittest.TestCase):
     v6net = ipaddress.IPv6Network(1)
     v6intf = ipaddress.IPv6Interface(1)
     v6addr_scoped = ipaddress.IPv6Address('::1%scope')
-    v6net_scoped= ipaddress.IPv6Network('::1%scope')
-    v6intf_scoped= ipaddress.IPv6Interface('::1%scope')
+    v6net_scoped = ipaddress.IPv6Network('::1%scope')
+    v6intf_scoped = ipaddress.IPv6Interface('::1%scope')
 
     v4_addresses = [v4addr, v4intf]
     v4_objects = v4_addresses + [v4net]
@@ -1083,6 +1083,7 @@ class IpaddrUnitTest(unittest.TestCase):
         self.ipv6_scoped_interface = ipaddress.IPv6Interface(
             '2001:658:22a:cafe:200:0:0:1%scope/64')
         self.ipv6_scoped_network = ipaddress.IPv6Network('2001:658:22a:cafe::%scope/64')
+        self.ipv6_with_ipv4_part = ipaddress.IPv6Interface('::1.2.3.4')
 
     def testRepr(self):
         self.assertEqual("IPv4Interface('1.2.3.4/32')",
@@ -1713,6 +1714,8 @@ class IpaddrUnitTest(unittest.TestCase):
 
         self.assertTrue(self.ipv6_scoped_interface ==
             ipaddress.IPv6Interface('2001:658:22a:cafe:200::1%scope/64'))
+        self.assertTrue(self.ipv6_with_ipv4_part ==
+            ipaddress.IPv6Interface('0000:0000:0000:0000:0000:0000:0102:0304'))
         self.assertFalse(self.ipv6_scoped_interface ==
             ipaddress.IPv6Interface('2001:658:22a:cafe:200::1%scope/63'))
         self.assertFalse(self.ipv6_scoped_interface ==
@@ -2195,6 +2198,7 @@ class IpaddrUnitTest(unittest.TestCase):
         self.assertEqual(self.ipv4_address.version, 4)
         self.assertEqual(self.ipv6_address.version, 6)
         self.assertEqual(self.ipv6_scoped_address.version, 6)
+        self.assertEqual(self.ipv6_with_ipv4_part.version, 6)
 
     def testMaxPrefixLength(self):
         self.assertEqual(ipaddress.IPv4Address.max_prefixlen, 32)