[1.0.X] Fixed the test case from [10399] to be more robust against the 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
This commit is contained in:
Jacob Kaplan-Moss 2009-04-05 17:54:40 +00:00
parent 33173e98c1
commit 734a3ac767
1 changed files with 16 additions and 9 deletions

View File

@ -39,6 +39,14 @@ class PostDeleteHandler(object):
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 @@ instance.id is None: False
>>> 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
"""}