<s> from contextlib import contextmanager <EOL> from mock import Mock <EOL> @ contextmanager <EOL> def mock_signal_receiver ( signal , wraps = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if wraps is None : <EOL> def wraps ( * args , ** kwargs ) : <EOL> return None <EOL> receiver = Mock ( wraps = wraps ) <EOL> signal . connect ( receiver , ** kwargs ) <EOL> yield receiver <EOL> signal . disconnect ( receiver ) </s>
