summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-05-28 21:54:02 (GMT)
committerGitHub <noreply@github.com>2018-05-28 21:54:02 (GMT)
commit416c1ebd9896b394790dcb4f9f035b1a44ebe9ff (patch)
treea5003eed8be41259a0e545fde1c2d22bf2ac23c7 /Lib/test
parentfdccfe09f0b10776645fdb04a0783d6864c32b21 (diff)
downloadcpython-416c1ebd9896b394790dcb4f9f035b1a44ebe9ff.zip
cpython-416c1ebd9896b394790dcb4f9f035b1a44ebe9ff.tar.gz
cpython-416c1ebd9896b394790dcb4f9f035b1a44ebe9ff.tar.bz2
bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index e5334c6..33300c9 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -1897,8 +1897,10 @@ class BaseTaskTests:
# See http://bugs.python.org/issue29271 for details:
asyncio.set_event_loop(self.loop)
try:
- self.assertEqual(asyncio.all_tasks(), {task})
- self.assertEqual(asyncio.all_tasks(None), {task})
+ with self.assertWarns(PendingDeprecationWarning):
+ self.assertEqual(Task.all_tasks(), {task})
+ with self.assertWarns(PendingDeprecationWarning):
+ self.assertEqual(Task.all_tasks(None), {task})
finally:
asyncio.set_event_loop(None)
@@ -2483,6 +2485,9 @@ class BaseTaskIntrospectionTests:
def _loop(self):
return loop
+ def done(self):
+ return False
+
task = TaskLike()
loop = mock.Mock()
@@ -2496,6 +2501,9 @@ class BaseTaskIntrospectionTests:
def get_loop(self):
return loop
+ def done(self):
+ return False
+
task = TaskLike()
loop = mock.Mock()
@@ -2504,6 +2512,23 @@ class BaseTaskIntrospectionTests:
self.assertEqual(asyncio.all_tasks(loop), {task})
self._unregister_task(task)
+ def test__register_task_3(self):
+ class TaskLike:
+ def get_loop(self):
+ return loop
+
+ def done(self):
+ return True
+
+ task = TaskLike()
+ loop = mock.Mock()
+
+ self.assertEqual(asyncio.all_tasks(loop), set())
+ self._register_task(task)
+ self.assertEqual(asyncio.all_tasks(loop), set())
+ self.assertEqual(asyncio.Task.all_tasks(loop), {task})
+ self._unregister_task(task)
+
def test__enter_task(self):
task = mock.Mock()
loop = mock.Mock()