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.
This commit is contained in:
parent
fd625c39d0
commit
f089196beb
|
@ -1064,8 +1064,9 @@ def main():
|
||||||
for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
|
for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
|
||||||
(eval_tests, "eval")):
|
(eval_tests, "eval")):
|
||||||
print(kind+"_results = [")
|
print(kind+"_results = [")
|
||||||
for s in statements:
|
for statement in statements:
|
||||||
print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
|
tree = ast.parse(statement, "?", kind)
|
||||||
|
print("%r," % (to_tuple(tree),))
|
||||||
print("]")
|
print("]")
|
||||||
print("main()")
|
print("main()")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
Loading…
Reference in New Issue