8000 gh-123409: fix `IPv6Address.reverse_pointer` output by picnixz · Pull Request #123419 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-123409: fix IPv6Address.reverse_pointer output #123419

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 3 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
picnixz committed Aug 28, 2024
commit 7168518316762ac1222ae290123cf3d3ada83d55
42 changes: 36 additions & 6 deletions Lib/test/test_ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2585,12 +2585,42 @@ def testExplodeShortHandIpStr(self):
self.assertEqual('192.168.178.1', addr4.exploded)

def testReversePointer(self):
addr1 = ipaddress.IPv4Address('127.0.0.1')
addr2 = ipaddress.IPv6Address('2001:db8::1')
self.assertEqual('1.0.0.127.in-addr.arpa', addr1.reverse_pointer)
self.assertEqual('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.' +
'b.d.0.1.0.0.2.ip6.arpa',
addr2.reverse_pointer)
for addr_v4, expected in [
('127.0.0.1', '1.0.0.127.in-addr.arpa'),
# test vector: https://www.rfc-editor.org/rfc/rfc1035, §3.5
('10.2.0.52', '52.0.2.10.in-addr.arpa'),
]:
with self.subTest('ipv4_reverse_pointer', addr=addr_v4):
addr = ipaddress.IPv4Address(addr_v4)
self.assertEqual(addr.reverse_pointer, expected)

for addr_v6, expected in [
(
'2001:db8::1', (
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.'
'0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.'
'ip6.arpa'
)
),
(
'::FFFF:192.168.1.35', (
'3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.'
'0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.'
'ip6.arpa'
)
),
# test vector: https://www.rfc-editor.org/rfc/rfc3596, §2.5
(
'4321:0:1:2:3:4:567:89ab', (
'b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.'
'2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.'
'ip6.arpa'
)
)
]:
with self.subTest('ipv6_reverse_pointer', addr=addr_v6):
addr = ipaddress.IPv6Address(addr_v6)
self.assertEqual(addr.reverse_pointer, expected)

def testIntRepresentation(self):
self.assertEqual(16909060, int(self.ipv4_address))
Expand Down
0