mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
This commit is contained in:
parent
66f8828bfc
commit
00e3372358
3 changed files with 228 additions and 62 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue