1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #18766 -- Pointed to pytz when LocalTimezone fails.

Thanks void for the report.
This commit is contained in:
Aymeric Augustin
2013-09-07 18:56:49 -05:00
parent b11564fd36
commit ded11aa620
2 changed files with 30 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import pickle
import unittest
from django.test.utils import override_settings
from django.utils import six
from django.utils import timezone
from django.utils.tzinfo import FixedOffset
@@ -20,6 +21,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()))