summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ipaddress.py
diff options
context:
space:
mode:
authors-sanjay <sanjay537@gmail.com>2017-04-01 06:09:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-04-01 06:09:53 (GMT)
commit7bd8d3e794782582a4ad1c9749424fff86802c3e (patch)
tree8d61336154beda73513828f3451ad62e894ac7fc /Lib/test/test_ipaddress.py
parent1f5425ff69ea0531d869b4f9fa28bd3f66ca3de7 (diff)
downloadcpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.zip
cpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.tar.gz
cpython-7bd8d3e794782582a4ad1c9749424fff86802c3e.tar.bz2
bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (#879)
the original logic was just comparing the network address but this is wrong because if the network address is equal then we need to compare the ip address for breaking the tie add more ip_interface comparison tests
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r--Lib/test/test_ipaddress.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index 0e39516..5d96330 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -1405,14 +1405,35 @@ class IpaddrUnitTest(unittest.TestCase):
ipaddress.ip_address('::2'))
def testInterfaceComparison(self):
- self.assertTrue(ipaddress.ip_interface('1.1.1.1') <=
- ipaddress.ip_interface('1.1.1.1'))
- self.assertTrue(ipaddress.ip_interface('1.1.1.1') <=
- ipaddress.ip_interface('1.1.1.2'))
- self.assertTrue(ipaddress.ip_interface('::1') <=
- ipaddress.ip_interface('::1'))
- self.assertTrue(ipaddress.ip_interface('::1') <=
- ipaddress.ip_interface('::2'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') ==
+ ipaddress.ip_interface('1.1.1.1/24'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.1/16') <
+ ipaddress.ip_interface('1.1.1.1/24'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') <
+ ipaddress.ip_interface('1.1.1.2/24'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.2/16') <
+ ipaddress.ip_interface('1.1.1.1/24'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') >
+ ipaddress.ip_interface('1.1.1.1/16'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.2/24') >
+ ipaddress.ip_interface('1.1.1.1/24'))
+ self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') >
+ ipaddress.ip_interface('1.1.1.2/16'))
+
+ self.assertTrue(ipaddress.ip_interface('::1/64') ==
+ ipaddress.ip_interface('::1/64'))
+ self.assertTrue(ipaddress.ip_interface('::1/64') <
+ ipaddress.ip_interface('::1/80'))
+ self.assertTrue(ipaddress.ip_interface('::1/64') <
+ ipaddress.ip_interface('::2/64'))
+ self.assertTrue(ipaddress.ip_interface('::2/48') <
+ ipaddress.ip_interface('::1/64'))
+ self.assertTrue(ipaddress.ip_interface('::1/80') >
+ ipaddress.ip_interface('::1/64'))
+ self.assertTrue(ipaddress.ip_interface('::2/64') >
+ ipaddress.ip_interface('::1/64'))
+ self.assertTrue(ipaddress.ip_interface('::1/64') >
+ ipaddress.ip_interface('::2/48'))
def testNetworkComparison(self):
# ip1 and ip2 have the same network address