8000 gh-87799: Improve the textual representation of IPv4-mapped IPv6 addresses by opavlyuk · Pull Request #29345 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-87799: Improve the textual representation of IPv4-mapped IPv6 addresses #29345

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 13 commits into from
Jul 31, 2023
Merged
Prev Previous commit
Next Next commit
bpo-43633 Update tests
  • Loading branch information
opavlyuk committed Apr 13, 2023
commit f3642caa4f27feb4e8fb19b35989f16a9316afa9
6 changes: 5 additions & 1 deletion Lib/test/test_ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,10 +1298,14 @@ def testGetIp(self):
'2001:658:22a:cafe:200::1')

def testIPv6IPv4MappedStringRepresentation(self):
ipv6_ipv4_mapped_str = '::ffff:1.2.3.4'
long_prefix_len = 30
prefix = '::ffff:'
ipv4 = '1.2.3.4'
ipv6_ipv4_mapped_str = '%s%s' % (prefix, ipv4)
ipv6_ipv4_mapped_address = ipaddress.IPv6Address(ipv6_ipv4_mapped_str)
ipv6_ipv4_mapped_interface = ipaddress.IPv6Interface(ipv6_ipv4_mapped_str)
self.assertEqual(str(ipv6_ipv4_mapped_address), ipv6_ipv4_mapped_str)
self.assertEqual(ipv6_ipv4_mapped_address.exploded, ipv6_ipv4_mapped_str.exploded[long_prefix_len] + ipv4)
self.assertEqual(str(ipv6_ipv4_mapped_interface.ip), ipv6_ipv4_mapped_str)

def testGetScopeId(self):
Expand Down
0