summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2017-10-06 03:24:46 (GMT)
committerYury Selivanov <yury@magic.io>2017-10-06 03:24:46 (GMT)
commitac317700ce7439e38a8b420218d9a5035bba92ed (patch)
treeddeb7d90f2e90b73a37783b88ef77376d9d996f5 /Lib/test
parent2084b30e540d88b9fc752c5bdcc2f24334af4f2b (diff)
downloadcpython-ac317700ce7439e38a8b420218d9a5035bba92ed.zip
cpython-ac317700ce7439e38a8b420218d9a5035bba92ed.tar.gz
cpython-ac317700ce7439e38a8b420218d9a5035bba92ed.tar.bz2
bpo-30406: Make async and await proper keywords (#1669)
Per PEP 492, 'async' and 'await' should become proper keywords in 3.7.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py6
-rw-r--r--Lib/test/test_coroutines.py24
-rw-r--r--Lib/test/test_parser.py6
-rw-r--r--Lib/test/test_tokenize.py28
4 files changed, 23 insertions, 41 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 7ff56b5..e23963a 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -231,12 +231,6 @@ class BaseTaskTests:
with self.assertRaises(TypeError):
asyncio.ensure_future('ok')
- def test_async_warning(self):
- f = self.new_future(self.loop)
- with self.assertWarnsRegex(DeprecationWarning,
- 'function is deprecated, use ensure_'):
- self.assertIs(f, asyncio.async(f))
-
def test_get_stack(self):
T = None
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index 2b79a17..ebd880b 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -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):
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 70cabb2..647d391 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -679,16 +679,16 @@ class IllegalSyntaxTestCase(unittest.TestCase):
def test_illegal_encoding(self):
# Illegal encoding declaration
tree = \
- (339,
+ (340,
(257, (0, '')))
self.check_bad_tree(tree, "missed encoding")
tree = \
- (339,
+ (340,
(257, (0, '')),
b'iso-8859-1')
self.check_bad_tree(tree, "non-string encoding")
tree = \
- (339,
+ (340,
(257, (0, '')),
'\udcff')
with self.assertRaises(UnicodeEncodeError):
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 21eee6d..3520a67 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -759,7 +759,7 @@ def"', """\
""")
self.check_tokenize("async def foo(): pass", """\
- ASYNC 'async' (1, 0) (1, 5)
+ NAME 'async' (1, 0) (1, 5)
NAME 'def' (1, 6) (1, 9)
NAME 'foo' (1, 10) (1, 13)
OP '(' (1, 13) (1, 14)
@@ -776,7 +776,7 @@ async def foo():
await
async += 1
''', """\
- ASYNC 'async' (1, 0) (1, 5)
+ NAME 'async' (1, 0) (1, 5)
NAME 'def' (1, 6) (1, 9)
NAME 'foo' (1, 10) (1, 13)
OP '(' (1, 13) (1, 14)
@@ -787,12 +787,12 @@ async += 1
NAME 'def' (2, 2) (2, 5)
NAME 'foo' (2, 6) (2, 9)
OP '(' (2, 9) (2, 10)
- AWAIT 'await' (2, 10) (2, 15)
+ NAME 'await' (2, 10) (2, 15)
OP ')' (2, 15) (2, 16)
OP ':' (2, 16) (2, 17)
NEWLINE '\\n' (2, 17) (2, 18)
INDENT ' ' (3, 0) (3, 4)
- AWAIT 'await' (3, 4) (3, 9)
+ NAME 'await' (3, 4) (3, 9)
OP '=' (3, 10) (3, 11)
NUMBER '1' (3, 12) (3, 13)
NEWLINE '\\n' (3, 13) (3, 14)
@@ -802,7 +802,7 @@ async += 1
OP ':' (4, 6) (4, 7)
NEWLINE '\\n' (4, 7) (4, 8)
INDENT ' ' (5, 0) (5, 4)
- AWAIT 'await' (5, 4) (5, 9)
+ NAME 'await' (5, 4) (5, 9)
NEWLINE '\\n' (5, 9) (5, 10)
DEDENT '' (6, 0) (6, 0)
DEDENT '' (6, 0) (6, 0)
@@ -815,7 +815,7 @@ async += 1
self.check_tokenize('''\
async def foo():
async for i in 1: pass''', """\
- ASYNC 'async' (1, 0) (1, 5)
+ NAME 'async' (1, 0) (1, 5)
NAME 'def' (1, 6) (1, 9)
NAME 'foo' (1, 10) (1, 13)
OP '(' (1, 13) (1, 14)
@@ -823,7 +823,7 @@ async def foo():
OP ':' (1, 15) (1, 16)
NEWLINE '\\n' (1, 16) (1, 17)
INDENT ' ' (2, 0) (2, 2)
- ASYNC 'async' (2, 2) (2, 7)
+ NAME 'async' (2, 2) (2, 7)
NAME 'for' (2, 8) (2, 11)
NAME 'i' (2, 12) (2, 13)
NAME 'in' (2, 14) (2, 16)
@@ -834,14 +834,14 @@ async def foo():
""")
self.check_tokenize('''async def foo(async): await''', """\
- ASYNC 'async' (1, 0) (1, 5)
+ NAME 'async' (1, 0) (1, 5)
NAME 'def' (1, 6) (1, 9)
NAME 'foo' (1, 10) (1, 13)
OP '(' (1, 13) (1, 14)
- ASYNC 'async' (1, 14) (1, 19)
+ NAME 'async' (1, 14) (1, 19)
OP ')' (1, 19) (1, 20)
OP ':' (1, 20) (1, 21)
- AWAIT 'await' (1, 22) (1, 27)
+ NAME 'await' (1, 22) (1, 27)
""")
self.check_tokenize('''\
@@ -866,7 +866,7 @@ def f():
OP ':' (3, 11) (3, 12)
NAME 'pass' (3, 13) (3, 17)
NEWLINE '\\n' (3, 17) (3, 18)
- ASYNC 'async' (4, 2) (4, 7)
+ NAME 'async' (4, 2) (4, 7)
NAME 'def' (4, 8) (4, 11)
NAME 'bar' (4, 12) (4, 15)
OP '(' (4, 15) (4, 16)
@@ -888,7 +888,7 @@ async def f():
async def bar(): pass
await = 2''', """\
- ASYNC 'async' (1, 0) (1, 5)
+ NAME 'async' (1, 0) (1, 5)
NAME 'def' (1, 6) (1, 9)
NAME 'f' (1, 10) (1, 11)
OP '(' (1, 11) (1, 12)
@@ -904,7 +904,7 @@ async def f():
OP ':' (3, 11) (3, 12)
NAME 'pass' (3, 13) (3, 17)
NEWLINE '\\n' (3, 17) (3, 18)
- ASYNC 'async' (4, 2) (4, 7)
+ NAME 'async' (4, 2) (4, 7)
NAME 'def' (4, 8) (4, 11)
NAME 'bar' (4, 12) (4, 15)
OP '(' (4, 15) (4, 16)
@@ -913,7 +913,7 @@ async def f():
NAME 'pass' (4, 19) (4, 23)
NEWLINE '\\n' (4, 23) (4, 24)
NL '\\n' (5, 0) (5, 1)
- AWAIT 'await' (6, 2) (6, 7)
+ NAME 'await' (6, 2) (6, 7)
OP '=' (6, 8) (6, 9)
NUMBER '2' (6, 10) (6, 11)
DEDENT '' (7, 0) (7, 0)