[Python-checkins] bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862)

miss-islington webhook-mailer at python.org
Tue May 3 14:18:41 EDT 2022


https://github.com/python/cpython/commit/30681d6655f1d25fd8ca10df0e2088a17733742c
commit: 30681d6655f1d25fd8ca10df0e2088a17733742c
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-03T11:18:31-07:00
summary:

bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862)


Co-authored-by: Jelle Zijlstra <jelle.zijlstra at gmail.com>
(cherry picked from commit b295a92c50b128e494f47c28f12b8e9eac2927ea)

Co-authored-by: Humbled Drugman <humbled.drugman at gmail.com>

files:
A Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst
M Lib/test/test_ipaddress.py

diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index b2bb609ea8b4b..f012af052322d 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -580,6 +580,10 @@ def assertBadAddress(addr, details):
         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 @@ def assertBadAddress(addr, details):
     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
index 0000000000000..38a06a2f9b6be
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2022-01-24-21-31-09.bpo-29890.zEG-ra.rst
@@ -0,0 +1,2 @@
+Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments.
+Original patch and tests by louisom.



More information about the Python-checkins mailing list