1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

[1.6.x] Fixed #18766 -- Pointed to pytz when LocalTimezone fails.

Thanks void for the report.

Backport of ded11aa6 from master.
This commit is contained in:
Aymeric Augustin
2013-09-07 18:56:49 -05:00
parent c03848b540
commit 7c31e195db
2 changed files with 30 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import copy
import datetime
import pickle
from django.test.utils import override_settings
from django.utils import six
from django.utils import timezone
from django.utils.tzinfo import FixedOffset
from django.utils import unittest
@@ -19,6 +20,12 @@ class TimezoneTests(unittest.TestCase):
local_now = timezone.localtime(now, local_tz)
self.assertEqual(local_now.tzinfo, local_tz)
def test_localtime_out_of_range(self):
local_tz = timezone.LocalTimezone()
long_ago = datetime.datetime(1900, 1, 1, tzinfo=timezone.utc)
with six.assertRaisesRegex(self, OverflowError, "install pytz"):
timezone.localtime(long_ago, local_tz)
def test_now(self):
with override_settings(USE_TZ=True):
self.assertTrue(timezone.is_aware(timezone.now()))