summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index e533d52..5b935b5 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -8,6 +8,7 @@ import random
import re
import sys
import traceback
+import types
import unittest
from unittest import mock
from types import GenericAlias
@@ -274,6 +275,20 @@ class BaseTaskTests:
loop.run_until_complete(fut)
self.assertEqual(fut.result(), 'ok')
+ def test_ensure_future_task_awaitable(self):
+ class Aw:
+ def __await__(self):
+ return asyncio.sleep(0, result='ok').__await__()
+
+ loop = asyncio.new_event_loop()
+ self.set_event_loop(loop)
+ task = asyncio.ensure_future(Aw(), loop=loop)
+ loop.run_until_complete(task)
+ self.assertTrue(task.done())
+ self.assertEqual(task.result(), 'ok')
+ self.assertIsInstance(task.get_coro(), types.CoroutineType)
+ loop.close()
+
def test_ensure_future_neither(self):
with self.assertRaises(TypeError):
asyncio.ensure_future('ok')