title: Testing that I have connected to a particular signal in Django
body: <p>I have a Django app called "publisher", it connects to various signals in my django project, and when it receives them it sends a message to a rabbitmq queue. What I want to do is to be able to test that my setup code is connecting to the correct signals.</p>
  
  <p>My app structure looks like:</p>
  
  <pre><code>publisher
      - __init__.py
      - signals.py
      - tests.py
  </code></pre>
  
  <p>my __init__.py looks like:</p>
  
  <pre><code>import signals
  </code></pre>
  
  <p>and my signals.py:</p>
  
  <pre><code>def receiver_function(*args, **kwargs):
      #Does rabbitmq stuff
  
  my_interesting_signal.connect(receiver_function)
  </code></pre>
  
  <p>I has thought about patching the receiver function, and checking that the mock was called when I sent the signal:</p>
  
  <p>tests.py:</p>
  
  <pre><code>class SignalsTeste(TestCase):
  
      def_test_connection(self):
  
          with patch('publisher.signals.receiver_function') as receiver_mock:
              my_interesting_signal.application_created.send(None)
              self.assertEquals(receiver_mock.call_count, 1)
  </code></pre>
  
  <p>However because the signals module is imported, and therefore the signal connections are made before the tests are run, this approach doesn't work as the connections are made before the function is patched......</p>
  
  <p>Can anyone suggest an alternative strategy?</p>