summaryrefslogtreecommitdiff
path: root/Lib/test/test_ipaddress.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-08-04 12:38:46 +0300
committerGitHub <noreply@github.com>2019-08-04 12:38:46 +0300
commit17e52649c0e7e9389f1cc2444a53f059e24e6bca (patch)
tree2cfdcdaefd375aaf93ef6973f507ffb768ee5472 /Lib/test/test_ipaddress.py
parent5c72badd06a962fe0018ceb9916f3ae66314ea8e (diff)
downloadcpython-git-17e52649c0e7e9389f1cc2444a53f059e24e6bca.tar.gz
bpo-37685: Fixed comparisons of datetime.timedelta and datetime.timezone. (GH-14996)
There was a discrepancy between the Python and C implementations. Add singletons ALWAYS_EQ, LARGEST and SMALLEST in test.support to test mixed type comparison.
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r--Lib/test/test_ipaddress.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index 9e17ea0c7a..de77111705 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -12,6 +12,7 @@ import operator
import pickle
import ipaddress
import weakref
+from test.support import LARGEST, SMALLEST
class BaseTestCase(unittest.TestCase):
@@ -673,20 +674,6 @@ class FactoryFunctionErrors(BaseTestCase):
self.assertFactoryError(ipaddress.ip_network, "network")
-@functools.total_ordering
-class LargestObject:
- def __eq__(self, other):
- return isinstance(other, LargestObject)
- def __lt__(self, other):
- return False
-
-@functools.total_ordering
-class SmallestObject:
- def __eq__(self, other):
- return isinstance(other, SmallestObject)
- def __gt__(self, other):
- return False
-
class ComparisonTests(unittest.TestCase):
v4addr = ipaddress.IPv4Address(1)
@@ -775,8 +762,6 @@ class ComparisonTests(unittest.TestCase):
def test_foreign_type_ordering(self):
other = object()
- smallest = SmallestObject()
- largest = LargestObject()
for obj in self.objects:
with self.assertRaises(TypeError):
obj < other
@@ -786,14 +771,14 @@ class ComparisonTests(unittest.TestCase):
obj <= other
with self.assertRaises(TypeError):
obj >= other
- self.assertTrue(obj < largest)
- self.assertFalse(obj > largest)
- self.assertTrue(obj <= largest)
- self.assertFalse(obj >= largest)
- self.assertFalse(obj < smallest)
- self.assertTrue(obj > smallest)
- self.assertFalse(obj <= smallest)
- self.assertTrue(obj >= smallest)
+ self.assertTrue(obj < LARGEST)
+ self.assertFalse(obj > LARGEST)
+ self.assertTrue(obj <= LARGEST)
+ self.assertFalse(obj >= LARGEST)
+ self.assertFalse(obj < SMALLEST)
+ self.assertTrue(obj > SMALLEST)
+ self.assertFalse(obj <= SMALLEST)
+ self.assertTrue(obj >= SMALLEST)
def test_mixed_type_key(self):
# with get_mixed_type_key, you can sort addresses and network.