bpo-30406: Make async and await proper keywords (#1669)

Per PEP 492, 'async' and 'await' should become proper keywords in 3.7.
This commit is contained in:
Jelle Zijlstra 2017-10-05 20:24:46 -07:00 committed by Yury Selivanov
parent 2084b30e54
commit ac317700ce
22 changed files with 419 additions and 623 deletions

View file

@ -167,34 +167,34 @@ class TestAsyncAwait(GrammarTest):
async def foo(): await x
""")
self.invalid_syntax("await x")
self.invalid_syntax("""def foo():
await x""")
self.validate("await x")
self.validate("""def foo():
await x""")
self.invalid_syntax("""def foo():
self.validate("""def foo():
def foo(): pass
async def foo(): pass
await x
""")
def test_async_var(self):
self.validate("""async = 1""")
self.validate("""await = 1""")
self.validate("""def async(): pass""")
self.invalid_syntax("""async = 1""")
self.invalid_syntax("""await = 1""")
self.invalid_syntax("""def async(): pass""")
def test_async_with(self):
self.validate("""async def foo():
async for a in b: pass""")
self.invalid_syntax("""def foo():
async for a in b: pass""")
self.validate("""def foo():
async for a in b: pass""")
def test_async_for(self):
self.validate("""async def foo():
async with a: pass""")
self.invalid_syntax("""def foo():
async with a: pass""")
self.validate("""def foo():
async with a: pass""")
class TestRaiseChanges(GrammarTest):
@ -477,3 +477,7 @@ def diff(fn, result):
os.remove("@")
except OSError:
pass
if __name__ == '__main__':
unittest.main()