diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2023-03-16 03:50:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 03:50:43 (GMT) |
commit | a44553ea9f7745a1119148082edb1fb0372ac0e2 (patch) | |
tree | 6cabbca3384325fb6e0c2a821e0ae37998315241 /Lib/test/test_asyncio | |
parent | 1c9f3391b916939e5ad18213e553f8d6bfbec25e (diff) | |
download | cpython-a44553ea9f7745a1119148082edb1fb0372ac0e2.zip cpython-a44553ea9f7745a1119148082edb1fb0372ac0e2.tar.gz cpython-a44553ea9f7745a1119148082edb1fb0372ac0e2.tar.bz2 |
GH-100112: avoid using iterable coroutines in asyncio internally (#100128)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 15 |
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') |