PEP 0492 -- Coroutines with async and await syntax. Issue #24017.

This commit is contained in:
Yury Selivanov 2015-05-11 22:57:16 -04:00
parent 4e6bf4b3da
commit 7544508f02
72 changed files with 9261 additions and 5739 deletions

View file

@ -63,6 +63,22 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
" if (yield):\n"
" yield x\n")
def test_await_statement(self):
self.check_suite("async def f():\n await smth()")
self.check_suite("async def f():\n foo = await smth()")
self.check_suite("async def f():\n foo, bar = await smth()")
self.check_suite("async def f():\n (await smth())")
self.check_suite("async def f():\n foo((await smth()))")
self.check_suite("async def f():\n await foo(); return 42")
def test_async_with_statement(self):
self.check_suite("async def f():\n async with 1: pass")
self.check_suite("async def f():\n async with a as b, c as d: pass")
def test_async_for_statement(self):
self.check_suite("async def f():\n async for i in (): pass")
self.check_suite("async def f():\n async for i, b in (): pass")
def test_nonlocal_statement(self):
self.check_suite("def f():\n"
" x = 0\n"