Example #1
0
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)
Example #2
0
    def assertRemoved(self, toremove, expected):

        root = ast.parse(toremove)

        remove_trivial(root)

        expected = ast.parse(expected)

        assert_ast_eq(self, root, expected)
Example #3
0
    def assertRemoved(self, toremove, expected):

        root = ast.parse(toremove)

        remove_trivial(root)

        expected = ast.parse(expected)

        assert_ast_eq(self, root, expected)
Example #4
0
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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)