diff --git a/tests/modeltests/signals/models.py b/tests/modeltests/signals/models.py index 06fd3a6fb3..ea8137f657 100644 --- a/tests/modeltests/signals/models.py +++ b/tests/modeltests/signals/models.py @@ -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 """}