mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
By default, != returns the opposite of ==, unless the latter returns
NotImplemented. (Is this worth backporting to 2.6? It seems so useful...!)
This commit is contained in:
parent
a4335b1e6b
commit
e27dc72308
3 changed files with 25 additions and 1 deletions
|
|
@ -39,6 +39,12 @@ class ComparisonTest(unittest.TestCase):
|
|||
self.assertEqual(a == b, id(a) == id(b),
|
||||
'a=%r, b=%r' % (a, b))
|
||||
|
||||
def test_ne_defaults_to_not_eq(self):
|
||||
a = Cmp(1)
|
||||
b = Cmp(1)
|
||||
self.assertTrue(a == b)
|
||||
self.assertFalse(a != b)
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(ComparisonTest)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue