Ticket #6915: 6915.regressiontest.diff

File 6915.regressiontest.diff, 1.5 KB (added by anonymous, 16 years ago)
  • tests/regressiontests/queries/models.py

     
    134134    def __unicode__(self):
    135135        return self.data
    136136
     137class Bug6915(models.Model):
     138    name = models.CharField(max_length=10)
    137139
     140    deleted = []
     141    def delete(self):
     142        super(Bug6915, self).delete()
     143        self.__class__.deleted.append(self)
     144   
     145    def __unicode__(self):
     146        return u"%s" % self.name
     147
    138148__test__ = {'API_TESTS':"""
    139149>>> t1 = Tag(name='t1')
    140150>>> t1.save()
     
    600610>>> Author.objects.filter(Q(extra__note=n1)|Q(item__note=n3)).filter(id=a1.id)
    601611[<Author: a1>]
    602612
     613Bug #6915
     614Make shure custom Model.delete() methods are called.
     615
     616>>> a = Bug6915(name="A")
     617>>> a.save()
     618>>> Bug6915.objects.all().delete()
     619>>> Bug6915.objects.all()
     620[]
     621>>> Bug6915.deleted
     622[<Bug6915: A>]
     623>>> a = Bug6915(name="A")
     624>>> a.save()
     625>>> b = Bug6915(name="B")
     626>>> b.save()
     627>>> Bug6915.objects.filter(name='B').delete()
     628>>> Bug6915.objects.all()
     629[<Bug6915: A>]
     630>>> Bug6915.deleted
     631[<Bug6915: A>, <Bug6915: B>]
     632>>> c=Bug6915(name="C")
     633>>> c.save()
     634>>> Bug6915.objects.order_by('name')[1:].delete()
     635>>> Bug6915.deleted
     636[<Bug6915: A>, <Bug6915: B>, <Bug6915: C>]
     637
    603638Bug #6981
    604639>>> Tag.objects.select_related('parent').order_by('name')
    605640[<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>]
Back to Top