human
Solve the following python programming problem given the following code:
@decorator
def assert_signal_called(signal, **expected):
assistant
#Here is the Python code you requested.

    """Context that verifes signal is called before exiting.
    """
    handler = Mock()
    def on_call(**kwargs):
        return handler(**kwargs)
    signal.connect(on_call)
    try:
        (yield handler)
    finally:
        signal.disconnect(on_call)
    handler.assert_called_with(signal=signal, **expected)