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:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user