test_unparse.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:typed-astunparse 作者: mbdevpl 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号