@contextlib.contextmanager
def mock_signal_receiver(signal, wraps=None, **kwargs):
    if wraps is None:
        def wraps(*args, **kwrags):
            return None

    receiver = mock.Mock(wraps=wraps)
    signal.connect(receiver, **kwargs)
    yield receiver
    signal.disconnect(receiver)
Temporarily attaches a receiver to the provided ``signal`` within the scope
dataset/ETHPy150Open dcramer/mock-django/mock_django/signals.py/mock_signal_receiver