diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 16:15:21 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-02-08 16:15:21 (GMT) |
commit | f089196beb0ad8fb262be42eddd92af3f0fe81c1 (patch) | |
tree | 25adac072536b1d48856f4fa7879327d84c1df8c | |
parent | fd625c39d0ffaf048acbbe3a5dade16bef483e1c (diff) | |
download | cpython-f089196beb0ad8fb262be42eddd92af3f0fe81c1.zip cpython-f089196beb0ad8fb262be42eddd92af3f0fe81c1.tar.gz cpython-f089196beb0ad8fb262be42eddd92af3f0fe81c1.tar.bz2 |
Simplify main() of test_ast
* Use ast.parse() to get the AST for a statement
* Use str%args syntax for format a line
Issue #26204.
-rw-r--r-- | Lib/test/test_ast.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 57060d8..f5c4ade 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1064,8 +1064,9 @@ def main(): for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), (eval_tests, "eval")): print(kind+"_results = [") - for s in statements: - print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",") + for statement in statements: + tree = ast.parse(statement, "?", kind) + print("%r," % (to_tuple(tree),)) print("]") print("main()") raise SystemExit |