Fixed #18176 -- Added test for year lookups with year < 1000

Thanks Tomas Ehrlich for the initial test
This commit is contained in:
Florian Hahn 2013-02-25 17:13:27 +01:00
parent 6d52bcbb7c
commit f28c301a47
1 changed files with 15 additions and 0 deletions

View File

@ -57,6 +57,7 @@ class ModelTests(TestCase):
Party.objects.create(when=datetime.datetime(1999, 12, 31)) Party.objects.create(when=datetime.datetime(1999, 12, 31))
Party.objects.create(when=datetime.datetime(1998, 12, 31)) Party.objects.create(when=datetime.datetime(1998, 12, 31))
Party.objects.create(when=datetime.datetime(1999, 1, 1)) Party.objects.create(when=datetime.datetime(1999, 1, 1))
Party.objects.create(when=datetime.datetime(1, 3, 3))
self.assertQuerysetEqual( self.assertQuerysetEqual(
Party.objects.filter(when__month=2), [] Party.objects.filter(when__month=2), []
) )
@ -104,6 +105,20 @@ class ModelTests(TestCase):
attrgetter("when") attrgetter("when")
) )
# Regression test for #18969
self.assertQuerysetEqual(
Party.objects.filter(when__year=1), [
datetime.date(1, 3, 3),
],
attrgetter("when")
)
self.assertQuerysetEqual(
Party.objects.filter(when__year='1'), [
datetime.date(1, 3, 3),
],
attrgetter("when")
)
def test_date_filter_null(self): def test_date_filter_null(self):
# Date filtering was failing with NULL date values in SQLite # Date filtering was failing with NULL date values in SQLite
# (regression test for #3501, amongst other things). # (regression test for #3501, amongst other things).