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

@ -394,20 +394,14 @@ class AsyncBadSyntaxTest(unittest.TestCase):
]
for code in samples:
with self.subTest(code=code), self.assertWarnsRegex(
DeprecationWarning,
"'await' will become reserved keywords"):
with self.subTest(code=code), self.assertRaises(SyntaxError):
compile(code, "<test>", "exec")
def test_badsyntax_3(self):
with self.assertRaises(DeprecationWarning):
with warnings.catch_warnings():
warnings.simplefilter("error")
compile("async = 1", "<test>", "exec")
def test_goodsyntax_1(self):
# Tests for issue 24619
with self.assertRaises(SyntaxError):
compile("async = 1", "<test>", "exec")
def test_badsyntax_4(self):
samples = [
'''def foo(await):
async def foo(): pass
@ -454,14 +448,8 @@ class AsyncBadSyntaxTest(unittest.TestCase):
]
for code in samples:
with self.subTest(code=code):
loc = {}
with warnings.catch_warnings():
warnings.simplefilter("ignore")
exec(code, loc, loc)
self.assertEqual(loc['foo'](10), 11)
with self.subTest(code=code), self.assertRaises(SyntaxError):
compile(code, "<test>", "exec")
class TokenizerRegrTest(unittest.TestCase):