from typing import Iterable
from typing import Callable


def assert_args_and_return_iter_over(retval: Iterable, *args, **kwargs) -> Callable:
    """
    Given an iterable return value and an arbitrary set of arguments, returns a callable which will return
    a fresh iterator over ``retval`` when called with arguments matching those specified here, otherwise will raise
    an ``AssertionError``.
    """
    def _inner(*inner_args, **inner_kwargs):
        assert args == inner_args
        assert kwargs == inner_kwargs
        return iter(retval)
    return _inner