Example #1
0
def test_objects_cmp_expression_one(patch, tree):
    """
    Ensures Objects.and_expression works with one node
    """
    patch.many(Objects, ['arith_expression'])
    tree.child(0).data = 'arith_expression'
    tree.children = [1]
    r = Objects.cmp_expression(tree)
    Objects.arith_expression.assert_called_with(tree.child(0))
    assert r == Objects.arith_expression()
Example #2
0
def test_objects_cmp_expression_two(patch, tree):
    """
    Ensures Objects.and_expression works with two nodes
    """
    patch.many(Objects, ['build_binary_expression', 'arith_expression'])
    tree.child(1).data = 'cmp_operator'
    tree.children = [1, '==', 2]
    cmp_expression = Objects.cmp_expression
    patch.object(Objects, 'cmp_expression')
    r = cmp_expression(tree)
    Objects.build_binary_expression.assert_called_with(
        tree, tree.child(1).child(0),
        Objects.cmp_expression(tree.child(0)),
        Objects.arith_expression(tree.child(2)))
    assert r == Objects.build_binary_expression()