mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Add asyncio.Handle.cancelled() method (#2388)
This commit is contained in:
parent
088929cf62
commit
69cfed1cd7
4 changed files with 14 additions and 4 deletions
|
@ -2305,10 +2305,10 @@ class HandleTests(test_utils.TestCase):
|
|||
h = asyncio.Handle(callback, args, self.loop)
|
||||
self.assertIs(h._callback, callback)
|
||||
self.assertIs(h._args, args)
|
||||
self.assertFalse(h._cancelled)
|
||||
self.assertFalse(h.cancelled())
|
||||
|
||||
h.cancel()
|
||||
self.assertTrue(h._cancelled)
|
||||
self.assertTrue(h.cancelled())
|
||||
|
||||
def test_callback_with_exception(self):
|
||||
def callback():
|
||||
|
@ -2494,11 +2494,11 @@ class TimerTests(unittest.TestCase):
|
|||
h = asyncio.TimerHandle(when, callback, args, mock.Mock())
|
||||
self.assertIs(h._callback, callback)
|
||||
self.assertIs(h._args, args)
|
||||
self.assertFalse(h._cancelled)
|
||||
self.assertFalse(h.cancelled())
|
||||
|
||||
# cancel
|
||||
h.cancel()
|
||||
self.assertTrue(h._cancelled)
|
||||
self.assertTrue(h.cancelled())
|
||||
self.assertIsNone(h._callback)
|
||||
self.assertIsNone(h._args)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue