def operands_of_mul_operation_must_support_mul(): type_bindings = {"x": types.none_type, "y": types.none_type} multiplication = nodes.mul(nodes.ref("x"), nodes.ref("y")) try: infer(multiplication, type_bindings=type_bindings) assert False, "Expected error" except errors.NoSuchAttributeError as error: assert_equal(nodes.attr(multiplication.left, "__mul__"), error.node) assert_equal(multiplication.left, ephemeral.root_node(error.node))
def can_infer_type_of_multiplication_operation(): type_bindings = {"x": types.int_type, "y": types.int_type} multiplication = nodes.mul(nodes.ref("x"), nodes.ref("y")) assert_equal(types.int_type, infer(multiplication, type_bindings=type_bindings))
def test_parse_multiplication(): expected = nodes.mul(nodes.ref("x"), nodes.ref("y")) _assert_expression_parse(expected, "x * y")