]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 3 May 2022 18:18:42 +0000 (11:18 -0700)
committerGitHub <noreply@github.com>
Tue, 3 May 2022 18:18:42 +0000 (11:18 -0700)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit b295a92c50b128e494f47c28f12b8e9eac2927ea)

Co-authored-by: Humbled Drugman <humbled.drugman@gmail.com>
Lib/test/test_ipaddress.py
Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst [new file with mode: 0644]

index 224412749340fb2372477ea50a07cd27c87b29df..90897f6bedb868b82a82118f9ac1b279168e69ae 100644 (file)
@@ -580,6 +580,10 @@ class NetmaskTestMixin_v4(CommonTestMixin_v4):
         assertBadAddress("1.2.3.256", re.escape("256 (> 255)"))
 
     def test_valid_netmask(self):
+        self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24')
+        self.assertEqual(str(self.factory(('192.0.2.0', '24'))), '192.0.2.0/24')
+        self.assertEqual(str(self.factory(('192.0.2.0', '255.255.255.0'))),
+                         '192.0.2.0/24')
         self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')),
                          '192.0.2.0/24')
         for i in range(0, 33):
@@ -740,6 +744,10 @@ class NetmaskTestMixin_v6(CommonTestMixin_v6):
     def test_valid_netmask(self):
         # We only support CIDR for IPv6, because expanded netmasks are not
         # standard notation.
+        self.assertEqual(str(self.factory(('2001:db8::', 32))),
+                         '2001:db8::/32')
+        self.assertEqual(str(self.factory(('2001:db8::', '32'))),
+                         '2001:db8::/32')
         self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32')
         for i in range(0, 129):
             # Generate and re-parse the CIDR format (trivial).
diff --git a/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst
new file mode 100644 (file)
index 0000000..38a06a2
--- /dev/null
@@ -0,0 +1,2 @@
+Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments.\r
+Original patch and tests by louisom.\r