Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(165469)

Delta Between Two Patch Sets: Lib/test/test_ipaddress.py

Issue 20480: Add ipaddress property to get reverse DNS name
Left Patch Set: Created 5 years, 10 months ago
Right Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/ipaddress.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # Copyright 2007 Google Inc. 1 # Copyright 2007 Google Inc.
2 # Licensed to PSF under a Contributor Agreement. 2 # Licensed to PSF under a Contributor Agreement.
3 3
4 """Unittest for ipaddress module.""" 4 """Unittest for ipaddress module."""
5 5
6 6
7 import unittest 7 import unittest
8 import re 8 import re
9 import contextlib 9 import contextlib
10 import operator 10 import operator
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 addr1.exploded) 1553 addr1.exploded)
1554 self.assertEqual('0000:0000:0000:0000:0000:0000:0000:0001/128', 1554 self.assertEqual('0000:0000:0000:0000:0000:0000:0000:0001/128',
1555 ipaddress.IPv6Interface('::1/128').exploded) 1555 ipaddress.IPv6Interface('::1/128').exploded)
1556 # issue 77 1556 # issue 77
1557 self.assertEqual('2001:0000:5ef5:79fd:0000:059d:a0e5:0ba1', 1557 self.assertEqual('2001:0000:5ef5:79fd:0000:059d:a0e5:0ba1',
1558 addr2.exploded) 1558 addr2.exploded)
1559 self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0000/96', 1559 self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0000/96',
1560 addr3.exploded) 1560 addr3.exploded)
1561 self.assertEqual('192.168.178.1', addr4.exploded) 1561 self.assertEqual('192.168.178.1', addr4.exploded)
1562 1562
1563 def testReverseName(self): 1563 def testReversePointer(self):
1564 addr1 = ipaddress.IPv4Address('127.0.0.1') 1564 addr1 = ipaddress.IPv4Address('127.0.0.1')
1565 addr2 = ipaddress.IPv6Address('2001:db8::1') 1565 addr2 = ipaddress.IPv6Address('2001:db8::1')
1566 self.assertEqual('1.0.0.127.in-addr.arpa.', addr1.reverse_name) 1566 self.assertEqual('1.0.0.127.in-addr.arpa', addr1.reverse_pointer)
1567 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.' + 1567 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.' +
1568 'b.d.0.1.0.0.2.ip6.arpa.', 1568 'b.d.0.1.0.0.2.ip6.arpa',
1569 addr2.reverse_name) 1569 addr2.reverse_pointer)
1570 1570
1571 def testIntRepresentation(self): 1571 def testIntRepresentation(self):
1572 self.assertEqual(16909060, int(self.ipv4_address)) 1572 self.assertEqual(16909060, int(self.ipv4_address))
1573 self.assertEqual(42540616829182469433547762482097946625, 1573 self.assertEqual(42540616829182469433547762482097946625,
1574 int(self.ipv6_address)) 1574 int(self.ipv6_address))
1575 1575
1576 def testForceVersion(self): 1576 def testForceVersion(self):
1577 self.assertEqual(ipaddress.ip_network(1).version, 4) 1577 self.assertEqual(ipaddress.ip_network(1).version, 4)
1578 self.assertEqual(ipaddress.IPv6Network(1).version, 6) 1578 self.assertEqual(ipaddress.IPv6Network(1).version, 6)
1579 1579
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 def testsixtofour(self): 1660 def testsixtofour(self):
1661 sixtofouraddr = ipaddress.ip_address('2002:ac1d:2d64::1') 1661 sixtofouraddr = ipaddress.ip_address('2002:ac1d:2d64::1')
1662 bad_addr = ipaddress.ip_address('2000:ac1d:2d64::1') 1662 bad_addr = ipaddress.ip_address('2000:ac1d:2d64::1')
1663 self.assertEqual(ipaddress.IPv4Address('172.29.45.100'), 1663 self.assertEqual(ipaddress.IPv4Address('172.29.45.100'),
1664 sixtofouraddr.sixtofour) 1664 sixtofouraddr.sixtofour)
1665 self.assertFalse(bad_addr.sixtofour) 1665 self.assertFalse(bad_addr.sixtofour)
1666 1666
1667 1667
1668 if __name__ == '__main__': 1668 if __name__ == '__main__':
1669 unittest.main() 1669 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+