Kaydet (Commit) 72502c12 authored tarafından Victor Stinner's avatar Victor Stinner

Issue #21163: Fix one more "Task was destroyed but it is pending!" log in tests

üst 7ba40610
...@@ -411,8 +411,10 @@ class TaskTests(test_utils.TestCase): ...@@ -411,8 +411,10 @@ class TaskTests(test_utils.TestCase):
loop.stop() loop.stop()
t = asyncio.Task(task(), loop=loop) t = asyncio.Task(task(), loop=loop)
self.assertRaises( with self.assertRaises(RuntimeError) as cm:
RuntimeError, loop.run_until_complete, t) loop.run_until_complete(t)
self.assertEqual(str(cm.exception),
'Event loop stopped before Future completed.')
self.assertFalse(t.done()) self.assertFalse(t.done())
self.assertEqual(x, 2) self.assertEqual(x, 2)
self.assertAlmostEqual(0.3, loop.time()) self.assertAlmostEqual(0.3, loop.time())
...@@ -420,6 +422,8 @@ class TaskTests(test_utils.TestCase): ...@@ -420,6 +422,8 @@ class TaskTests(test_utils.TestCase):
# close generators # close generators
for w in waiters: for w in waiters:
w.close() w.close()
t.cancel()
self.assertRaises(asyncio.CancelledError, loop.run_until_complete, t)
def test_wait_for(self): def test_wait_for(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment