summaryrefslogtreecommitdiff
path: root/tests/datetimes
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@sixmedia.com>2013-11-14 16:32:55 +0700
committerBaptiste Mispelon <bmispelon@gmail.com>2013-11-14 21:36:55 +0100
commit17ed99f3a3eea4bd27fa34be59c3582616ed8079 (patch)
tree4f68a1baa8934f3bdfecb0cc0b959a3954f2cdcd /tests/datetimes
parent3e845b79ce9f74c0942e2c41259d33bd835f2941 (diff)
Fixed #21432 -- DateTimeQuery now copies tzinfo when cloning.
Thanks Enrique Martínez for the report and @bmispelon for the tests.
Diffstat (limited to 'tests/datetimes')
-rw-r--r--tests/datetimes/tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/datetimes/tests.py b/tests/datetimes/tests.py
index f54b30d967..ee0b676664 100644
--- a/tests/datetimes/tests.py
+++ b/tests/datetimes/tests.py
@@ -1,8 +1,16 @@
from __future__ import unicode_literals
import datetime
+from unittest import skipIf
+
+try:
+ import pytz
+except ImportError:
+ pytz = None
+
+from django.test import TestCase, override_settings
+from django.utils import timezone
-from django.test import TestCase
from .models import Article, Comment, Category
@@ -81,3 +89,11 @@ class DateTimesTests(TestCase):
],
lambda d: d,
)
+
+ @skipIf(pytz is None, "this test requires pytz")
+ @override_settings(USE_TZ=True)
+ def test_21432(self):
+ now = timezone.localtime(timezone.now().replace(microsecond=0))
+ Article.objects.create(title="First one", pub_date=now)
+ qs = Article.objects.datetimes('pub_date', 'second')
+ self.assertEqual(qs[0], now)