Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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