예제 #1
0
def raise_value_cannot_be_non_subtype_of_exception():
    type_bindings = {"error": types.object_type}
    ref_node = nodes.ref("error")
    try:
        update_context(nodes.raise_(ref_node), type_bindings=type_bindings)
        assert False, "Expected error"
    except errors.UnexpectedValueTypeError as error:
        assert_equal(ref_node, error.node)
예제 #2
0
def raise_statement_has_child_names_resolved():
    _assert_children_resolved(
        lambda ref: nodes.raise_(ref),
    )
예제 #3
0
def has_unconditional_return_is_true_if_list_contains_a_raise_statement():
    assert returns.has_unconditional_return([
        nodes.raise_(nodes.ref("error"))
    ])
예제 #4
0
def test_parse_raise():
    _assert_statement_parse(nodes.raise_(nodes.ref("x")), "raise x")
예제 #5
0
def raise_value_can_be_instance_of_exception():
    type_bindings = {"error": types.exception_type}
    assert_statement_type_checks(nodes.raise_(nodes.ref("error")), type_bindings=type_bindings)
예제 #6
0
def raise_value_can_be_instance_of_subtype_of_exception():
    cls = types.class_type("BlahError", {}, base_classes=[types.exception_type])
    type_bindings = {"error": cls}
    assert_statement_type_checks(nodes.raise_(nodes.ref("error")), type_bindings=type_bindings)
예제 #7
0
 def test_transform_raise_statement_transforms_value(self):
     _assert_transform(
         nodes.raise_(nodes.ref("value")),
         cc.raise_(cc.ref("value"))
     )