Skip to content

bpo-29890: Test IPv*Interface construction with tuple argument #30862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/test_ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,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):
Expand Down Expand Up @@ -739,6 +743,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).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add tests for :class:`ipaddress.IPv4Interface` and :class:`ipaddress.IPv6Interface` construction with tuple arguments.
Original patch and tests by louisom.