Esempio n. 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)
Esempio n. 2
0
def raise_statement_has_child_names_resolved():
    _assert_children_resolved(
        lambda ref: nodes.raise_(ref),
    )
Esempio n. 3
0
def has_unconditional_return_is_true_if_list_contains_a_raise_statement():
    assert returns.has_unconditional_return([
        nodes.raise_(nodes.ref("error"))
    ])
Esempio n. 4
0
def test_parse_raise():
    _assert_statement_parse(nodes.raise_(nodes.ref("x")), "raise x")
Esempio n. 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)
Esempio n. 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)
Esempio n. 7
0
 def test_transform_raise_statement_transforms_value(self):
     _assert_transform(
         nodes.raise_(nodes.ref("value")),
         cc.raise_(cc.ref("value"))
     )