mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
This commit is contained in:
parent
4c69be22df
commit
662db125cd
23 changed files with 1295 additions and 1150 deletions
|
@ -11,7 +11,7 @@ import time
|
|||
import random
|
||||
|
||||
from test import support
|
||||
from test.support import script_helper
|
||||
from test.support import script_helper, ALWAYS_EQ
|
||||
|
||||
# Used in ReferencesTestCase.test_ref_created_during_del() .
|
||||
ref_from_del = None
|
||||
|
@ -794,6 +794,10 @@ class ReferencesTestCase(TestBase):
|
|||
self.assertTrue(a != c)
|
||||
self.assertTrue(a == d)
|
||||
self.assertFalse(a != d)
|
||||
self.assertFalse(a == x)
|
||||
self.assertTrue(a != x)
|
||||
self.assertTrue(a == ALWAYS_EQ)
|
||||
self.assertFalse(a != ALWAYS_EQ)
|
||||
del x, y, z
|
||||
gc.collect()
|
||||
for r in a, b, c:
|
||||
|
@ -1102,6 +1106,9 @@ class WeakMethodTestCase(unittest.TestCase):
|
|||
_ne(a, f)
|
||||
_ne(b, e)
|
||||
_ne(b, f)
|
||||
# Compare with different types
|
||||
_ne(a, x.some_method)
|
||||
_eq(a, ALWAYS_EQ)
|
||||
del x, y, z
|
||||
gc.collect()
|
||||
# Dead WeakMethods compare by identity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue