def simple_case(self, toremove, expected): root = ast.parse(toremove) remove_trivial(root) expected_root = ast.parse(expected) assert_ast_eq(self, root, expected_root)
def assertRemoved(self, toremove, expected): root = ast.parse(toremove) remove_trivial(root) expected = ast.parse(expected) assert_ast_eq(self, root, expected)
def test_replace_non_existant(self): root = ast.parse('a = 1') name_a = root.body[0].targets[0] name_b = ast.Name(id='b', ctx=ast.Store()) replace_nodes(root, name_b, name_a) expected = ast.parse('a = 1') assert_ast_eq(self, root, expected)
def assertPruned(self, source, pruned, symbols): mutator = PruneVisitor(symbols=symbols, mode='inclusive') orig_ast = ast.parse(source) expected_ast = ast.parse(pruned) mutator.visit(orig_ast) assert_ast_eq(self, orig_ast, expected_ast) tested.update(orig_ast)