summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-01-06 00:09:11 (GMT)
committerGuido van Rossum <guido@python.org>2008-01-06 00:09:11 (GMT)
commitab078ddb4f8a7ac68f54a3c7f110f4d82e82b16f (patch)
tree471d852049d8c8525ca9dd6aea46d9e549ce9ea7 /Lib
parent673f7efa08850e42d077cab38683be2e4764b876 (diff)
downloadcpython-ab078ddb4f8a7ac68f54a3c7f110f4d82e82b16f.zip
cpython-ab078ddb4f8a7ac68f54a3c7f110f4d82e82b16f.tar.gz
cpython-ab078ddb4f8a7ac68f54a3c7f110f4d82e82b16f.tar.bz2
Issue #1393: object_richcompare() returns NotImplemented instead of
False if the objects aren't equal, to give the other side a chance.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_compare.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py
index c660837..15fe3c2 100644
--- a/Lib/test/test_compare.py
+++ b/Lib/test/test_compare.py
@@ -16,6 +16,13 @@ class Cmp:
def __eq__(self, other):
return self.arg == other
+class Anything:
+ def __eq__(self, other):
+ return True
+
+ def __ne__(self, other):
+ return False
+
class ComparisonTest(unittest.TestCase):
set1 = [2, 2.0, 2, 2+0j, Cmp(2.0)]
set2 = [[1], (3,), None, Empty()]
@@ -45,6 +52,15 @@ class ComparisonTest(unittest.TestCase):
self.assertTrue(a == b)
self.assertFalse(a != b)
+ def test_issue_1393(self):
+ x = lambda: None
+ self.assertEqual(x, Anything())
+ self.assertEqual(Anything(), x)
+ y = object()
+ self.assertEqual(y, Anything())
+ self.assertEqual(Anything(), y)
+
+
def test_main():
test_support.run_unittest(ComparisonTest)