diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-02-04 08:53:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-04 08:53:48 (GMT) |
commit | 07ca9afaa8768b44baf816b4998d209ed3e0088f (patch) | |
tree | acb09f5cd6a660acb41d77c150cdd6236bf02d96 /Lib/test/test_grammar.py | |
parent | 8b5fa289fdb04b6b919cf95fa99246aa872e47a8 (diff) | |
download | cpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.zip cpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.tar.gz cpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.tar.bz2 |
bpo-10544: Disallow "yield" in comprehensions and generator expressions. (GH-4564)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 88c22b8..d89bfdc 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -251,6 +251,8 @@ class CNS: class GrammarTests(unittest.TestCase): + check_syntax_error = check_syntax_error + # single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE # XXX can't test in a script -- this rule is only used when interactive @@ -920,15 +922,7 @@ class GrammarTests(unittest.TestCase): def g(): [x for x in [(yield 1)]] def g(): [x for x in [(yield from ())]] - def check(code, warntext): - with self.assertWarnsRegex(DeprecationWarning, warntext): - compile(code, '<test string>', 'exec') - import warnings - with warnings.catch_warnings(): - warnings.filterwarnings('error', category=DeprecationWarning) - with self.assertRaisesRegex(SyntaxError, warntext): - compile(code, '<test string>', 'exec') - + check = self.check_syntax_error check("def g(): [(yield x) for x in ()]", "'yield' inside list comprehension") check("def g(): [x for x in () if not (yield x)]", |