Пример #1
0
    def test_select_expr_contains(self):
        "Checks that a contains operation uses contains module"
        l = ast.LiteralSet([ast.Number(1), ast.Number(2)])
        r = ast.Literal('bar')
        c = ast.ContainsOperator(l, r)
        name = merge.node_name(c)

        with patch('pypred.merge.contains.select_rewrite_expression') as cr:
            merge.select_rewrite_expression(DEEP, name, [c])
            assert cr.called
Пример #2
0
    def test_select_expr_compare(self):
        "Checks that a compare operation uses compare module"
        l = ast.Literal('foo')
        r = ast.Literal('bar')
        n = ast.CompareOperator('>', l, r)
        name = merge.node_name(n)

        with patch('pypred.merge.compare.select_rewrite_expression') as c:
            merge.select_rewrite_expression(name, [n])
            assert c.called
Пример #3
0
    def test_select_expr_contains(self):
        "Checks that a contains operation uses contains module"
        l = ast.LiteralSet([ast.Number(1), ast.Number(2)])
        r = ast.Literal('bar')
        c = ast.ContainsOperator(l, r)
        name = merge.node_name(c)

        with patch('pypred.merge.contains.select_rewrite_expression') as cr:
            merge.select_rewrite_expression(DEEP, name, [c])
            assert cr.called
Пример #4
0
    def test_select_expr_compare(self):
        "Checks that a compare operation uses compare module"
        l = ast.Literal('foo')
        r = ast.Literal('bar')
        n = ast.CompareOperator('>', l, r)
        name = merge.node_name(n)

        with patch('pypred.merge.compare.select_rewrite_expression') as c:
            merge.select_rewrite_expression(DEEP, name, [n])
            assert c.called
Пример #5
0
 def test_select_expr_logical(self):
     "Checks that a logical operation is not selected"
     l = ast.Literal('foo')
     r = ast.Literal('bar')
     n = ast.LogicalOperator('or', l, r)
     name = merge.node_name(n)
     expr = merge.select_rewrite_expression(name, [n])
     assert expr == l
     n.left = None
     expr = merge.select_rewrite_expression(name, [n])
     assert expr == r
Пример #6
0
 def test_select_expr_logical(self):
     "Checks that a logical operation is not selected"
     l = ast.Literal('foo')
     r = ast.Literal('bar')
     n = ast.LogicalOperator('or', l, r)
     name = merge.node_name(n)
     expr = merge.select_rewrite_expression(DEEP, name, [n])
     assert expr == l
     n.left = None
     expr = merge.select_rewrite_expression(DEEP, name, [n])
     assert expr == r
Пример #7
0
 def test_select_expr_first(self):
     "Checks that first expression is selected"
     l = ast.Literal('foo')
     r = ast.Literal('bar')
     name = merge.node_name(l)
     expr = merge.select_rewrite_expression(name, [l, r])
     assert expr == l
Пример #8
0
 def test_select_expr_negate(self):
     "Checks that a negate operation is not selected"
     l = ast.Literal('foo')
     n = ast.NegateOperator(l)
     name = merge.node_name(n)
     expr = merge.select_rewrite_expression(name, [n])
     assert expr == l
Пример #9
0
 def test_select_expr_first(self):
     "Checks that first expression is selected"
     l = ast.Literal('foo')
     r = ast.Literal('bar')
     name = merge.node_name(l)
     expr = merge.select_rewrite_expression(DEEP, name, [l, r])
     assert expr == l
Пример #10
0
 def test_select_expr_negate(self):
     "Checks that a negate operation is not selected"
     l = ast.Literal('foo')
     n = ast.NegateOperator(l)
     name = merge.node_name(n)
     expr = merge.select_rewrite_expression(DEEP, name, [n])
     assert expr == l