Added a test for month selection under SQLite in case an old possible bug ever

resurfaces. Patch from Pilippe Raoult.

Fixed #659


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7359 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-03-24 14:19:12 +00:00
parent 89e7b673d8
commit 23912ebbe2
1 changed files with 17 additions and 0 deletions

View File

@ -26,6 +26,9 @@ class Movie(models.Model):
movie_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=60)
class Party(models.Model):
when = models.DateField()
__test__ = {'API_TESTS': """
(NOTE: Part of the regression test here is merely parsing the model
declaration. The verbose_name, in particular, did not always work.)
@ -51,5 +54,19 @@ u''
>>> len(a4.article_text)
5000
# #659 regression test
>>> import datetime
>>> p = Party.objects.create(when = datetime.datetime(1999, 12, 31))
>>> p = Party.objects.create(when = datetime.datetime(1998, 12, 31))
>>> p = Party.objects.create(when = datetime.datetime(1999, 1, 1))
>>> [p.when for p in Party.objects.filter(when__month = 2)]
[]
>>> [p.when for p in Party.objects.filter(when__month = 1)]
[datetime.date(1999, 1, 1)]
>>> [p.when for p in Party.objects.filter(when__month = 12)]
[datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)]
>>> [p.when for p in Party.objects.filter(when__year = 1998)]
[datetime.date(1998, 12, 31)]
"""
}