summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-01 13:23:12 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-01 13:23:12 (GMT)
commit697a526fa1426b4d490cfa98bbf0b0c2889fa759 (patch)
tree9a82b27b69ea5a91d1773da65a3fd6c73b556ca2 /Lib/test/test_functools.py
parenta2d86228d52ba4d2d31c3dbb9f53670b1e5f4951 (diff)
downloadcpython-697a526fa1426b4d490cfa98bbf0b0c2889fa759.zip
cpython-697a526fa1426b4d490cfa98bbf0b0c2889fa759.tar.gz
cpython-697a526fa1426b4d490cfa98bbf0b0c2889fa759.tar.bz2
Issue #23132: Improve performance and introspection support of comparison
methods created by functool.total_ordering.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 1012053..fbb43e4 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -880,6 +880,24 @@ class TestTotalOrdering(unittest.TestCase):
with self.assertRaises(TypeError):
a <= b
+ def test_pickle(self):
+ for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
+ for name in '__lt__', '__gt__', '__le__', '__ge__':
+ with self.subTest(method=name, proto=proto):
+ method = getattr(Orderable_LT, name)
+ method_copy = pickle.loads(pickle.dumps(method, proto))
+ self.assertIs(method_copy, method)
+
+@functools.total_ordering
+class Orderable_LT:
+ def __init__(self, value):
+ self.value = value
+ def __lt__(self, other):
+ return self.value < other.value
+ def __eq__(self, other):
+ return self.value == other.value
+
+
class TestLRU(unittest.TestCase):
def test_lru(self):