Ticket #6141: test.diff

File test.diff, 1.1 KB (added by Doug Van Horn, 16 years ago)

Patches the unit test to expose the problem.

  • tests/modeltests/basic/models.py

     
    390390>>> Article.objects.get(pk=a.id).headline
    391391u'\u6797\u539f \u3081\u3050\u307f'
    392392"""
     393
     394# Create another Article class to test __year queries on a DateField.
     395class Article2(models.Model):
     396    headline = models.CharField(max_length=100, default='No title given.')
     397    pub_date = models.DateField()
     398
     399    class Meta:
     400        ordering = ('pub_date', 'headline')
     401
     402    def __unicode__(self):
     403        return self.headline
     404__test__['API_TESTS'] += """
     405
     406# Edge-case test: A year lookup on a DateField should retrieve all
     407# objects in the give year, including Jan. 1 and Dec. 31.
     408>>> from datetime import date
     409>>> a2_1 = Article2.objects.create(headline='Article2 1', pub_date=date(2008, 1, 1))
     410>>> a2_2 = Article2.objects.create(headline='Article2 2', pub_date=date(2008, 12, 31))
     411>>> Article2.objects.filter(pub_date__year=2008)
     412[<Article2: Article2 1>, <Article2: Article2 2>]
     413"""
Back to Top