Issue #24325, #24400: Add more unittests for types.coroutine; tweak wrapper implementation.

This commit is contained in:
Yury Selivanov 2015-06-24 11:44:51 -04:00
parent 66f8828bfc
commit 00e3372358
3 changed files with 228 additions and 62 deletions

View file

@ -1,6 +1,7 @@
"""Tests support for new syntax introduced by PEP 492."""
import collections.abc
import types
import unittest
from test import support
@ -164,5 +165,23 @@ class CoroutineTests(BaseTest):
self.loop.run_until_complete(start())
def test_types_coroutine(self):
def gen():
yield from ()
return 'spam'
@types.coroutine
def func():
return gen()
async def coro():
wrapper = func()
self.assertIsInstance(wrapper, types._GeneratorWrapper)
return await wrapper
data = self.loop.run_until_complete(coro())
self.assertEqual(data, 'spam')
if __name__ == '__main__':
unittest.main()