test_fatoptimizer.py 文件源码

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

项目:fatoptimizer 作者: vstinner 项目源码 文件源码
def check_call_visitor(self, visitor):
        tree = ast.parse("1+1")
        with self.assertRaises(Exception) as cm:
            visitor.visit(tree)

        binop = tree.body[0].value
        what = ast.dump(binop)
        self.assertEqual(str(cm.exception),
                         'error at <string>:1 on visiting %s: bug' % what)

        # Test truncature of the AST dump
        with mock.patch('fatoptimizer.tools.COMPACT_DUMP_MAXLEN', 5):
            with self.assertRaises(Exception) as cm:
                visitor.visit(tree)

            what = 'BinOp(...)'
            self.assertEqual(str(cm.exception),
                             'error at <string>:1 on visiting %s: bug' % what)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号