Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move signal disconnect into finally block

  • Loading branch information...
commit 6045efa029dcae58ec6aab20bdcb0dc325851048 1 parent d53e3b1
David Cramer dcramer authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 tests/modeltests/delete/tests.py
10 tests/modeltests/delete/tests.py
View
@@ -233,13 +233,15 @@ def test_relational_post_delete_signals_happen_before_parent_object(self):
def log_post_delete(instance, **kwargs):
self.assertTrue(R.objects.filter(pk=instance.r_id))
- models.signals.post_delete.connect(log_post_delete, sender=S)
-
r = R.objects.create(pk=1)
S.objects.create(pk=1, r=r)
- r.delete()
- models.signals.post_delete.disconnect(log_post_delete)
+ models.signals.post_delete.connect(log_post_delete, sender=S)
+
+ try:
+ r.delete()
+ finally:
+ models.signals.post_delete.disconnect(log_post_delete)
@skipUnlessDBFeature("can_defer_constraint_checks")
def test_can_defer_constraint_checks(self):
Please sign in to comment.
Something went wrong with that request. Please try again.