Ticket #7853: 7853-r8016-tests.diff

File 7853-r8016-tests.diff, 1.0 KB (added by Russell Keith-Magee, 16 years ago)

Test case demonstrating problem

  • regressiontests/model_inheritance_regress/models.py

     
    4949class Child(Parent):
    5050    name = models.CharField(max_length=10)
    5151
     52class SelfRefParent(models.Model):
     53    parent_data = models.IntegerField()
     54    self_data = models.ForeignKey('self', null=True)
     55   
     56class SelfRefChild(SelfRefParent):
     57    child_data = models.IntegerField()
     58   
    5259__test__ = {'API_TESTS':"""
    5360# Regression for #7350, #7202
    5461# Check that when you create a Parent object with a specific reference to an
     
    159166...
    160167DoesNotExist: ItalianRestaurant matching query does not exist.
    161168
     169# Regression test for #7853
     170# If the parent class has a self-referential link,
     171# hilarity ensues during deletion of a child object
     172
     173>>> obj = SelfRefChild.objects.create(child_data=37, parent_data=42)
     174>>> obj.delete()
     175
    162176"""}
Back to Top