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