def returns_true_or_raises(f):
    """A safety net.

    Decorator for functions that are only allowed to return True or raise
    an exception.

    Args:
        f: A function whose only expected return value is True.

    Returns:
        A wrapped functions whose guaranteed only return value is True.
    """
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        ret = f(*args, **kwargs)
        if ret is not True:
            raise RuntimeError("Unexpected return value %r" % ret)
        return True
    return wrapped
A safety net.

    Decorator for functions that are only allowed to return True or raise
    an exception.

    Args:
        f: A function whose only expected return value is True.

    Returns:
        A wrapped functions whose guaranteed only return value is True.