Fixed the test case from [10399] to be more robust against the order in which test cases are executed.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-04-05 17:54:02 +00:00
parent 8da2322cad
commit dd966f081a
1 changed files with 16 additions and 9 deletions

View File

@ -39,6 +39,14 @@ class PostDeleteHandler(object):
post_delete_test = PostDeleteHandler() post_delete_test = PostDeleteHandler()
__test__ = {'API_TESTS':""" __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.pre_save.connect(pre_save_test)
>>> models.signals.post_save.connect(post_save_test) >>> models.signals.post_save.connect(post_save_test)
>>> models.signals.pre_delete.connect(pre_delete_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.post_save.disconnect(post_save_test)
>>> models.signals.pre_save.disconnect(pre_save_test) >>> models.signals.pre_save.disconnect(pre_save_test)
# Make sure all the signals got removed properly (#9989) # Check that all our signals got disconnected properly.
>>> models.signals.post_delete.receivers >>> post_signals = (len(models.signals.pre_save.receivers),
[] ... len(models.signals.post_save.receivers),
>>> models.signals.pre_delete.receivers ... len(models.signals.pre_delete.receivers),
[] ... len(models.signals.post_delete.receivers))
>>> models.signals.post_save.receivers
[] >>> pre_signals == post_signals
>>> models.signals.pre_save.receivers True
[]
"""} """}