Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Unified Diff: Lib/test/test_asyncio/test_tasks.py

Issue 29271: Task.current_task(None) returns unexpected result
Patch Set: Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Modules/_asynciomodule.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_asyncio/test_tasks.py Fri Jan 13 19:18:33 2017 +0000
+++ b/Lib/test/test_asyncio/test_tasks.py Fri Jan 13 17:17:17 2017 -0500
@@ -1461,6 +1461,14 @@
def coro(loop):
self.assertTrue(Task.current_task(loop=loop) is task)
+ # See http://bugs.python.org/issue29271 for details:
+ asyncio.set_event_loop(loop)
+ try:
+ self.assertTrue(Task.current_task(None) is task)
+ self.assertTrue(Task.current_task() is task)
+ finally:
+ asyncio.set_event_loop(None)
+
task = self.new_task(self.loop, coro(self.loop))
self.loop.run_until_complete(task)
self.assertIsNone(Task.current_task(loop=self.loop))
@@ -1805,8 +1813,17 @@
# schedule the task
coro = kill_me(self.loop)
task = asyncio.ensure_future(coro, loop=self.loop)
+
self.assertEqual(Task.all_tasks(loop=self.loop), {task})
+ # See http://bugs.python.org/issue29271 for details:
+ asyncio.set_event_loop(self.loop)
+ try:
+ self.assertEqual(Task.all_tasks(), {task})
+ self.assertEqual(Task.all_tasks(None), {task})
+ finally:
+ asyncio.set_event_loop(None)
+
# execute the task so it waits for future
self.loop._run_once()
self.assertEqual(len(self.loop._ready), 0)
« no previous file with comments | « no previous file | Modules/_asynciomodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+