mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Issue #23266: Restore the performance of ipaddress.collapse_addresses() whith
duplicated addresses and simplify the code.
This commit is contained in:
parent
1202a4733e
commit
b53f0fbf96
2 changed files with 25 additions and 25 deletions
|
@ -790,11 +790,15 @@ class IpaddrUnitTest(unittest.TestCase):
|
|||
2 ** ipaddress.IPV6LENGTH)
|
||||
|
||||
def testInternals(self):
|
||||
first, last, nitems = ipaddress._find_address_range([
|
||||
ipaddress.IPv4Address('10.10.10.10'),
|
||||
ipaddress.IPv4Address('10.10.10.12')])
|
||||
self.assertEqual(first, last)
|
||||
self.assertEqual(nitems, 1)
|
||||
ip1 = ipaddress.IPv4Address('10.10.10.10')
|
||||
ip2 = ipaddress.IPv4Address('10.10.10.11')
|
||||
ip3 = ipaddress.IPv4Address('10.10.10.12')
|
||||
self.assertEqual(list(ipaddress._find_address_range([ip1])),
|
||||
[(ip1, ip1)])
|
||||
self.assertEqual(list(ipaddress._find_address_range([ip1, ip3])),
|
||||
[(ip1, ip1), (ip3, ip3)])
|
||||
self.assertEqual(list(ipaddress._find_address_range([ip1, ip2, ip3])),
|
||||
[(ip1, ip3)])
|
||||
self.assertEqual(128, ipaddress._count_righthand_zero_bits(0, 128))
|
||||
self.assertEqual("IPv4Network('1.2.3.0/24')", repr(self.ipv4_network))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue