Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move signal disconnect into finally block

  • Loading branch information...
commit 6045efa029dcae58ec6aab20bdcb0dc325851048 1 parent d53e3b1
David Cramer authored

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  tests/modeltests/delete/tests.py
10  tests/modeltests/delete/tests.py
@@ -233,13 +233,15 @@ def test_relational_post_delete_signals_happen_before_parent_object(self):
233 233
         def log_post_delete(instance, **kwargs):
234 234
             self.assertTrue(R.objects.filter(pk=instance.r_id))
235 235
 
236  
-        models.signals.post_delete.connect(log_post_delete, sender=S)
237  
-
238 236
         r = R.objects.create(pk=1)
239 237
         S.objects.create(pk=1, r=r)
240  
-        r.delete()
241 238
 
242  
-        models.signals.post_delete.disconnect(log_post_delete)
  239
+        models.signals.post_delete.connect(log_post_delete, sender=S)
  240
+
  241
+        try:
  242
+            r.delete()
  243
+        finally:
  244
+            models.signals.post_delete.disconnect(log_post_delete)
243 245
 
244 246
     @skipUnlessDBFeature("can_defer_constraint_checks")
245 247
     def test_can_defer_constraint_checks(self):

0 notes on commit 6045efa

Please sign in to comment.
Something went wrong with that request. Please try again.