def test_files(self):
"""Keep Python stdlib tree the same after roundtrip parse-unparse."""
for path in PATHS:
with open(path, 'r', encoding='utf-8') as py_file:
original_code = py_file.read()
tree = typed_ast.ast3.parse(source=original_code, filename=path)
code = typed_astunparse.unparse(tree)
roundtrip_tree = typed_ast.ast3.parse(source=code)
tree_dump = typed_ast.ast3.dump(tree, include_attributes=False)
roundtrip_tree_dump = typed_ast.ast3.dump(roundtrip_tree, include_attributes=False)
self.assertEqual(tree_dump, roundtrip_tree_dump, msg=path)
评论列表
文章目录