mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #21432 -- DateTimeQuery now copies tzinfo when cloning.
Thanks Enrique Martínez for the report and @bmispelon for the tests.
This commit is contained in:
parent
3e845b79ce
commit
17ed99f3a3
2 changed files with 22 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue