summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-05-07 15:36:33 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-05-07 15:36:33 (GMT)
commit72f6095d4fc50c0e92ea0f88df898ffe67cdb67c (patch)
treecd4e893521406cd0efa2eb10a6f494722a9cc53f /Lib/test/test_parser.py
parent0576f9b4cf7e4b373eff1e610d6c63682a0ce089 (diff)
parent11c1dee183a39626a904f3f9e09b47dab3fd8117 (diff)
downloadcpython-72f6095d4fc50c0e92ea0f88df898ffe67cdb67c.zip
cpython-72f6095d4fc50c0e92ea0f88df898ffe67cdb67c.tar.gz
cpython-72f6095d4fc50c0e92ea0f88df898ffe67cdb67c.tar.bz2
Issue #14697: Merge fix from 3.2.
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 8eb3ee3..f911319 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -309,6 +309,29 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
"except Exception as e:\n"
" raise ValueError from e\n")
+ def test_set_displays(self):
+ self.check_expr('{2}')
+ self.check_expr('{2,}')
+ self.check_expr('{2, 3}')
+ self.check_expr('{2, 3,}')
+
+ def test_dict_displays(self):
+ self.check_expr('{}')
+ self.check_expr('{a:b}')
+ self.check_expr('{a:b,}')
+ self.check_expr('{a:b, c:d}')
+ self.check_expr('{a:b, c:d,}')
+
+ def test_set_comprehensions(self):
+ self.check_expr('{x for x in seq}')
+ self.check_expr('{f(x) for x in seq}')
+ self.check_expr('{f(x) for x in seq if condition(x)}')
+
+ def test_dict_comprehensions(self):
+ self.check_expr('{x:x for x in seq}')
+ self.check_expr('{x**2:x[3] for x in seq if condition(x)}')
+ self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}')
+
#
# Second, we take *invalid* trees and make sure we get ParserError