diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 16:36:33 +0100 |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-05-07 16:36:33 +0100 |
commit | 7191ec30ea7c02099a943cf3e2a8fc58486a2cc0 (patch) | |
tree | 71141cc9536fbb55c69fcf80a5feef650497b0a9 /Lib/test/test_parser.py | |
parent | f135d4233df7d43c4db60242c1236dd5f60ff668 (diff) | |
parent | 0e02afc338646ea6206592ff5c132a43f8b86ac4 (diff) | |
download | cpython-7191ec30ea7c02099a943cf3e2a8fc58486a2cc0.tar.gz |
Issue #14697: Merge fix from 3.2.
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r-- | Lib/test/test_parser.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 8eb3ee3b34..f91131969f 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 |