def test_reraise_unhandled_exceptions():
    """
    Unhandled exceptions shoud be re-raised
    """
    def fn():
        raise UnhandledException("some error occurred")

    def handle_test_exception():
        state["val"] = 42

    handler_map = {TestException: handle_test_exception}

    handle = dict_to_handler(handler_map)

    handle_exceptions(handle, fn)()
def test_handle_exceptions():
    """
    The correct handler should be called
    """
    state = {}

    def fn():
        raise TestException("some error occurred")

    def handle_test_exception():
        state["val"] = 42

    handler_map = {TestException: handle_test_exception}

    handle = dict_to_handler(handler_map)

    handle_exceptions(handle, fn)()

    assert_equal(state["val"], 42)