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)
评论列表
文章目录