From ad583a8e6de1ea023d2b20b72a1910465ecfc82c Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sat, 30 May 2015 21:04:37 -0400 Subject: Issue 24004: Add a unittest for @asyncio.coroutine supporting Awaitables --- Lib/test/test_asyncio/test_pep492.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index 8fc6cba..d123f08 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -106,6 +106,19 @@ class CoroutineTests(BaseTest): 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__': unittest.main() -- cgit v0.12