Skip to content

Commit 30681d6

Browse files
bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862)
Co-authored-by: Jelle Zijlstra <[email protected]> (cherry picked from commit b295a92) Co-authored-by: Humbled Drugman <[email protected]>
1 parent 58f2d2d commit 30681d6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Lib/test/test_ipaddress.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ def assertBadAddress(addr, details):
580580
assertBadAddress("1.2.3.256", re.escape("256 (> 255)"))
581581

582582
def test_valid_netmask(self):
583+
self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24')
584+
self.assertEqual(str(self.factory(('192.0.2.0', '24'))), '192.0.2.0/24')
585+
self.assertEqual(str(self.factory(('192.0.2.0', '255.255.255.0'))),
586+
'192.0.2.0/24')
583587
self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')),
584588
'192.0.2.0/24')
585589
for i in range(0, 33):
@@ -740,6 +744,10 @@ def assertBadAddress(addr, details):
740744
def test_valid_netmask(self):
741745
# We only support CIDR for IPv6, because expanded netmasks are not
742746
# standard notation.
747+
self.assertEqual(str(self.factory(('2001:db8::', 32))),
748+
'2001:db8::/32')
749+
self.assertEqual(str(self.factory(('2001:db8::', '32'))),
750+
'2001:db8::/32')
743751
self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32')
744752
for i in range(0, 129):
745753
# Generate and re-parse the CIDR format (trivial).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments.
2+
Original patch and tests by louisom.

0 commit comments

Comments
 (0)