From f28c301a4720ef110643728192c27b2ca0ed193a Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 25 Feb 2013 17:13:27 +0100 Subject: [PATCH] Fixed #18176 -- Added test for year lookups with year < 1000 Thanks Tomas Ehrlich for the initial test --- tests/regressiontests/model_regress/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/regressiontests/model_regress/tests.py b/tests/regressiontests/model_regress/tests.py index c90fe98658..e2d30f0ecc 100644 --- a/tests/regressiontests/model_regress/tests.py +++ b/tests/regressiontests/model_regress/tests.py @@ -57,6 +57,7 @@ class ModelTests(TestCase): Party.objects.create(when=datetime.datetime(1999, 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(1, 3, 3)) self.assertQuerysetEqual( Party.objects.filter(when__month=2), [] ) @@ -104,6 +105,20 @@ class ModelTests(TestCase): 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): # Date filtering was failing with NULL date values in SQLite # (regression test for #3501, amongst other things).