Move signal disconnect into finally block
This commit is contained in:
parent
d53e3b15ee
commit
6045efa029
|
@ -233,12 +233,14 @@ class DeletionTests(TestCase):
|
|||
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.connect(log_post_delete, sender=S)
|
||||
|
||||
try:
|
||||
r.delete()
|
||||
finally:
|
||||
models.signals.post_delete.disconnect(log_post_delete)
|
||||
|
||||
@skipUnlessDBFeature("can_defer_constraint_checks")
|
||||
|
|
Loading…
Reference in New Issue