summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-05-06 21:54:34 (GMT)
committerGitHub <noreply@github.com>2020-05-06 21:54:34 (GMT)
commit99db2a1db7a9b468a0ce8377d579f78fa03a2a34 (patch)
tree5752707eb45888e127ba1ae74721f2237a878f97 /Lib
parent441416c9a06f11f28e17d56c915ea6116c0c9ea7 (diff)
downloadcpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.zip
cpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.tar.gz
cpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.tar.bz2
bpo-40334: Allow trailing comma in parenthesised context managers (GH-19964)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_grammar.py66
1 files changed, 65 insertions, 1 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 922a516..c24d352 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1,7 +1,7 @@
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
-from test.support import check_syntax_error, check_syntax_warning
+from test.support import check_syntax_error, check_syntax_warning, use_old_parser
import inspect
import unittest
import sys
@@ -1694,6 +1694,70 @@ class GrammarTests(unittest.TestCase):
with manager() as x, manager():
pass
+ if not use_old_parser():
+ test_cases = [
+ """if 1:
+ with (
+ manager()
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as x
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as (x, y),
+ manager() as z,
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager(),
+ manager()
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as x,
+ manager() as y
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as x,
+ manager()
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as x,
+ manager() as y,
+ manager() as z,
+ ):
+ pass
+ """,
+ """if 1:
+ with (
+ manager() as x,
+ manager() as y,
+ manager(),
+ ):
+ pass
+ """,
+ ]
+ for case in test_cases:
+ with self.subTest(case=case):
+ compile(case, "<string>", "exec")
+
+
def test_if_else_expr(self):
# Test ifelse expressions in various cases
def _checkeval(msg, ret):