Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.0.X] Fixed the test case from [10399] to be more robust against th…

…e order in which test cases are executed. Backport of r10402 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 734a3ac767ab5f8b752f3372e19ca2c7ada42979 1 parent 33173e9
@jacobian jacobian authored
Showing with 16 additions and 9 deletions.
  1. +16 −9 tests/modeltests/signals/models.py
View
25 tests/modeltests/signals/models.py
@@ -39,6 +39,14 @@ def __call__(self, signal, sender, instance, **kwargs):
post_delete_test = PostDeleteHandler()
__test__ = {'API_TESTS':"""
+
+# Save up the number of connected signals so that we can check at the end
+# that all the signals we register get properly unregistered (#9989)
+>>> pre_signals = (len(models.signals.pre_save.receivers),
+... len(models.signals.post_save.receivers),
+... len(models.signals.pre_delete.receivers),
+... len(models.signals.post_delete.receivers))
+
>>> models.signals.pre_save.connect(pre_save_test)
>>> models.signals.post_save.connect(post_save_test)
>>> models.signals.pre_delete.connect(pre_delete_test)
@@ -97,14 +105,13 @@ def __call__(self, signal, sender, instance, **kwargs):
>>> models.signals.post_save.disconnect(post_save_test)
>>> models.signals.pre_save.disconnect(pre_save_test)
-# Make sure all the signals got removed properly (#9989)
->>> models.signals.post_delete.receivers
-[]
->>> models.signals.pre_delete.receivers
-[]
->>> models.signals.post_save.receivers
-[]
->>> models.signals.pre_save.receivers
-[]
+# Check that all our signals got disconnected properly.
+>>> post_signals = (len(models.signals.pre_save.receivers),
+... len(models.signals.post_save.receivers),
+... len(models.signals.pre_delete.receivers),
+... len(models.signals.post_delete.receivers))
+
+>>> pre_signals == post_signals
+True
"""}
Please sign in to comment.
Something went wrong with that request. Please try again.