Esempio n. 1
0
 def test_mutate_elision(self):
     class ConstRemover(BaseVisitor):
         def visitConst(self, const):
             return None
     listast = source2ast(FakeSpace(), "[1, 2]")
     listast = listast.mutate(ConstRemover())
     listnode = listast.node.nodes[0].expr
     assert isinstance(listnode, ast.List)
     assert len(listnode.nodes) == 0
Esempio n. 2
0
 def test_mutate_elision(self):
     from parser import source2ast, ASTConst, ASTList
     class ConstRemover(self.BaseVisitor):
         def visitConst(self, const):
             return None
     listast = source2ast("[1, 2]")
     listast = listast.mutate(ConstRemover())
     listnode = listast.node.nodes[0].expr
     assert isinstance(listnode, ASTList)
     assert len(listnode.nodes) == 0
Esempio n. 3
0
    def test_mutate_elision(self):
        class ConstRemover(BaseVisitor):
            def visitConst(self, const):
                return None

        listast = source2ast(FakeSpace(), "[1, 2]")
        listast = listast.mutate(ConstRemover())
        listnode = listast.node.nodes[0].expr
        assert isinstance(listnode, ast.List)
        assert len(listnode.nodes) == 0
Esempio n. 4
0
    def test_mutate_strange_cases(self):
        src = '''
if a:
    b
        '''
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '''
try:
    b
except Exception:
    pass
        '''
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '{1:2}'
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '1 > 3'
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
Esempio n. 5
0
    def test_mutate_strange_cases(self):
        src = '''
if a:
    b
        '''
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '''
try:
    b
except Exception:
    pass
        '''
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '{1:2}'
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
        src = '1 > 3'
        ast = source2ast(FakeSpace(), src)
        ast.mutate(BaseVisitor())
Esempio n. 6
0
    def test_mutate_elision(self):
        from parser import source2ast, ASTConst, ASTList

        class ConstRemover(self.BaseVisitor):
            def visitConst(self, const):
                return None

        listast = source2ast("[1, 2]")
        listast = listast.mutate(ConstRemover())
        listnode = listast.node.nodes[0].expr
        assert isinstance(listnode, ASTList)
        assert len(listnode.nodes) == 0