]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-32415: Add more tests (#4995)
authorYury Selivanov <yury@magic.io>
Sat, 23 Dec 2017 20:42:27 +0000 (15:42 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Dec 2017 20:42:27 +0000 (15:42 -0500)
Lib/test/test_asyncio/test_tasks.py

index 84669cd6c7ec87b3c87a0897d10021ea94b6ca9d..7bb43058c8052904b72dd16fad9f4334040594af 100644 (file)
@@ -2308,10 +2308,28 @@ class BaseTaskIntrospectionTests:
     _enter_task = None
     _leave_task = None
 
-    def test__register_task(self):
-        task = mock.Mock()
+    def test__register_task_1(self):
+        class TaskLike:
+            @property
+            def _loop(self):
+                return loop
+
+        task = TaskLike()
         loop = mock.Mock()
-        task.get_loop = lambda: loop
+
+        self.assertEqual(asyncio.all_tasks(loop), set())
+        self._register_task(task)
+        self.assertEqual(asyncio.all_tasks(loop), {task})
+        self._unregister_task(task)
+
+    def test__register_task_2(self):
+        class TaskLike:
+            def get_loop(self):
+                return loop
+
+        task = TaskLike()
+        loop = mock.Mock()
+
         self.assertEqual(asyncio.all_tasks(loop), set())
         self._register_task(task)
         self.assertEqual(asyncio.all_tasks(loop), {task})