mirror of
https://github.com/python/cpython.git
synced 2025-09-19 23:20:25 +00:00
Issue 24004: Add a unittest for @asyncio.coroutine supporting Awaitables
This commit is contained in:
parent
353f2299bf
commit
ad583a8e6d
1 changed files with 13 additions and 0 deletions
|
@ -106,6 +106,19 @@ class CoroutineTests(BaseTest):
|
||||||
|
|
||||||
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
||||||
|
|
||||||
|
def test_function_returning_awaitable(self):
|
||||||
|
class Awaitable:
|
||||||
|
def __await__(self):
|
||||||
|
return ('spam',)
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def func():
|
||||||
|
return Awaitable()
|
||||||
|
|
||||||
|
coro = func()
|
||||||
|
self.assertEquals(coro.send(None), 'spam')
|
||||||
|
coro.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue