from typing import Callable


def assert_args_and_return_or_raise(retval, e, *args, **kwargs) -> Callable:
    """
    Given a return value and an arbitrary set of arguments, returns a callable which will return ``retval`` when called
    with arguments matching those specified here, otherwise will raise the exception ``e``.
    """
    def _inner(*inner_args, **inner_kwargs):
        if args == inner_args and kwargs == inner_kwargs:
            return retval
        else:
            raise e
    return _inner