Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve test to ensure that post_delete was actually called

  • Loading branch information...
commit a7ed09d13d9532089bd2380edab1df5df96082a6 1 parent abbb888
David Cramer authored

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  tests/modeltests/delete/tests.py
7  tests/modeltests/delete/tests.py
@@ -230,8 +230,12 @@ def log_pre_delete(sender, **kwargs):
230 230
         models.signals.post_delete.disconnect(log_pre_delete)
231 231
 
232 232
     def test_relational_post_delete_signals_happen_before_parent_object(self):
  233
+        deletions = []
  234
+
233 235
         def log_post_delete(instance, **kwargs):
234 236
             self.assertTrue(R.objects.filter(pk=instance.r_id))
  237
+            self.assertEquals(type(instance), S)
  238
+            deletions.append(instance.id)
235 239
 
236 240
         r = R.objects.create(pk=1)
237 241
         S.objects.create(pk=1, r=r)
@@ -243,6 +247,9 @@ def log_post_delete(instance, **kwargs):
243 247
         finally:
244 248
             models.signals.post_delete.disconnect(log_post_delete)
245 249
 
  250
+        self.assertEquals(len(deletions), 1)
  251
+        self.assertEquals(deletions[0], 1)
  252
+
246 253
     @skipUnlessDBFeature("can_defer_constraint_checks")
247 254
     def test_can_defer_constraint_checks(self):
248 255
         u = User.objects.create(

0 notes on commit a7ed09d

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