summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2017-12-23 20:04:15 (GMT)
committerGitHub <noreply@github.com>2017-12-23 20:04:15 (GMT)
commitca9b36cd1a384e5ecb56d9df9a59144240353ef0 (patch)
tree3efb5c02ae40b61eb5c6391d3144d0f2f26cd616 /Lib/test/test_asyncio/test_tasks.py
parent558aa30f7971e087c4a00b1f49cc2ef3195c01ca (diff)
downloadcpython-ca9b36cd1a384e5ecb56d9df9a59144240353ef0.zip
cpython-ca9b36cd1a384e5ecb56d9df9a59144240353ef0.tar.gz
cpython-ca9b36cd1a384e5ecb56d9df9a59144240353ef0.tar.bz2
bpo-32415: Add asyncio.Task.get_loop() and Future.get_loop() (#4992)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index f1dbb99..84669cd 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -141,6 +141,7 @@ class BaseTaskTests:
self.assertTrue(t.done())
self.assertEqual(t.result(), 'ok')
self.assertIs(t._loop, self.loop)
+ self.assertIs(t.get_loop(), self.loop)
loop = asyncio.new_event_loop()
self.set_event_loop(loop)
@@ -2310,10 +2311,11 @@ class BaseTaskIntrospectionTests:
def test__register_task(self):
task = mock.Mock()
loop = mock.Mock()
+ task.get_loop = lambda: loop
self.assertEqual(asyncio.all_tasks(loop), set())
- self._register_task(loop, task)
+ self._register_task(task)
self.assertEqual(asyncio.all_tasks(loop), {task})
- self._unregister_task(loop, task)
+ self._unregister_task(task)
def test__enter_task(self):
task = mock.Mock()
@@ -2360,14 +2362,15 @@ class BaseTaskIntrospectionTests:
def test__unregister_task(self):
task = mock.Mock()
loop = mock.Mock()
- self._register_task(loop, task)
- self._unregister_task(loop, task)
+ task.get_loop = lambda: loop
+ self._register_task(task)
+ self._unregister_task(task)
self.assertEqual(asyncio.all_tasks(loop), set())
def test__unregister_task_not_registered(self):
task = mock.Mock()
loop = mock.Mock()
- self._unregister_task(loop, task)
+ self._unregister_task(task)
self.assertEqual(asyncio.all_tasks(loop), set())