Skip to content

Commit b295a92

Browse files
bpo-29890: Test IPv*Interface construction with tuple argument (#30862)
Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 77e7a04 commit b295a92

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
@@ -579,6 +579,10 @@ def assertBadAddress(addr, details):
579579
assertBadAddress("1.2.3.256", re.escape("256 (> 255)"))
580580

581581
def test_valid_netmask(self):
582+
self.assertEqual(str(self.factory(('192.0.2.0', 24))), '192.0.2.0/24')
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', '255.255.255.0'))),
585+
'192.0.2.0/24')
582586
self.assertEqual(str(self.factory('192.0.2.0/255.255.255.0')),
583587
'192.0.2.0/24')
584588
for i in range(0, 33):
@@ -739,6 +743,10 @@ def assertBadAddress(addr, details):
739743
def test_valid_netmask(self):
740744
# We only support CIDR for IPv6, because expanded netmasks are not
741745
# standard notation.
746+
self.assertEqual(str(self.factory(('2001:db8::', 32))),
747+
'2001:db8::/32')
748+
self.assertEqual(str(self.factory(('2001:db8::', '32'))),
749+
'2001:db8::/32')
742750
self.assertEqual(str(self.factory('2001:db8::/32')), '2001:db8::/32')
743751
for i in range(0, 129):
744752
# 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)