Created
May 6, 2011 13:00
-
-
Save berinhard/958910 to your computer and use it in GitHub Desktop.
Testing Django Signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.test import TestCase | |
| from your_app.signals import your_signal | |
| class YourTestClass(TestClass): | |
| @classmethod | |
| def setUpClass(cls): | |
| # Save original receivers | |
| cls.signal_receivers = your_signal.receivers | |
| # Erase them | |
| your_signal.receivers = [] | |
| @classmethod | |
| def tearDownClass(cls): | |
| # Recover original receivers | |
| your_signal.receivers = cls.signal_receivers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment