changeset: 100190:a0d053899ff8 user: Victor Stinner date: Mon Feb 08 17:15:21 2016 +0100 files: Lib/test/test_ast.py description: 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. diff -r ec12fbf449a5 -r a0d053899ff8 Lib/test/test_ast.py --- a/Lib/test/test_ast.py Mon Feb 08 17:57:22 2016 +0200 +++ b/Lib/test/test_ast.py Mon Feb 08 17:15:21 2016 +0100 @@ -1064,8 +1064,9 @@ 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