From: Yury Selivanov Date: Sun, 31 May 2015 01:04:37 +0000 (-0400) Subject: Issue 24004: Add a unittest for @asyncio.coroutine supporting Awaitables X-Git-Tag: v3.5.0b3~133 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ad583a8e6de1ea023d2b20b72a1910465ecfc82c;p=thirdparty%2FPython%2Fcpython.git Issue 24004: Add a unittest for @asyncio.coroutine supporting Awaitables --- diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index 8fc6cba1312e..d123f088cb6a 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()