Example #1
0
def operands_of_sub_operation_must_support_sub():
    type_bindings = {"x": types.none_type, "y": types.none_type}
    subtraction = nodes.sub(nodes.ref("x"), nodes.ref("y"))
    try:
        infer(subtraction, type_bindings=type_bindings)
        assert False, "Expected error"
    except errors.NoSuchAttributeError as error:
        assert_equal(nodes.attr(subtraction.left, "__sub__"), error.node)
Example #2
0
def can_infer_type_of_subtraction_operation():
    type_bindings = {"x": types.int_type, "y": types.int_type}
    subtraction = nodes.sub(nodes.ref("x"), nodes.ref("y"))
    assert_equal(types.int_type, infer(subtraction, type_bindings=type_bindings))
Example #3
0
def test_parse_subtraction():
    expected = nodes.sub(nodes.ref("x"), nodes.ref("y"))
    _assert_expression_parse(expected, "x - y")