human
Complete the below
@decorator
def assert_signal_called(signal, **expected):

    ''''Context that verifes signal is called before exiting.'
    '''
assistant
#Here is the Python code you requested.
    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)