mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +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
|
@ -32,6 +32,7 @@ from asyncio import proactor_events
|
|||
from asyncio import selector_events
|
||||
from test.test_asyncio import utils as test_utils
|
||||
from test import support
|
||||
from test.support import ALWAYS_EQ, LARGEST, SMALLEST
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
|
@ -2364,6 +2365,28 @@ class TimerTests(unittest.TestCase):
|
|||
self.assertIs(NotImplemented, h1.__eq__(h3))
|
||||
self.assertIs(NotImplemented, h1.__ne__(h3))
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
h1 < ()
|
||||
with self.assertRaises(TypeError):
|
||||
h1 > ()
|
||||
with self.assertRaises(TypeError):
|
||||
h1 <= ()
|
||||
with self.assertRaises(TypeError):
|
||||
h1 >= ()
|
||||
self.assertFalse(h1 == ())
|
||||
self.assertTrue(h1 != ())
|
||||
|
||||
self.assertTrue(h1 == ALWAYS_EQ)
|
||||
self.assertFalse(h1 != ALWAYS_EQ)
|
||||
self.assertTrue(h1 < LARGEST)
|
||||
self.assertFalse(h1 > LARGEST)
|
||||
self.assertTrue(h1 <= LARGEST)
|
||||
self.assertFalse(h1 >= LARGEST)
|
||||
self.assertFalse(h1 < SMALLEST)
|
||||
self.assertTrue(h1 > SMALLEST)
|
||||
self.assertFalse(h1 <= SMALLEST)
|
||||
self.assertTrue(h1 >= SMALLEST)
|
||||
|
||||
|
||||
class AbstractEventLoopTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue