1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

Improve test to ensure that post_delete was actually called

This commit is contained in:
David Cramer 2013-01-14 13:18:24 -08:00
parent abbb88886b
commit a7ed09d13d

View File

@ -230,8 +230,12 @@ class DeletionTests(TestCase):
models.signals.post_delete.disconnect(log_pre_delete)
def test_relational_post_delete_signals_happen_before_parent_object(self):
deletions = []
def log_post_delete(instance, **kwargs):
self.assertTrue(R.objects.filter(pk=instance.r_id))
self.assertEquals(type(instance), S)
deletions.append(instance.id)
r = R.objects.create(pk=1)
S.objects.create(pk=1, r=r)
@ -243,6 +247,9 @@ class DeletionTests(TestCase):
finally:
models.signals.post_delete.disconnect(log_post_delete)
self.assertEquals(len(deletions), 1)
self.assertEquals(deletions[0], 1)
@skipUnlessDBFeature("can_defer_constraint_checks")
def test_can_defer_constraint_checks(self):
u = User.objects.create(