From 306607d5b99b6eca6ae2c1e726d8eb32b9b2ca1b Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 9 Sep 2021 15:15:44 +0200 Subject: Fixed #32365 -- Made zoneinfo the default timezone implementation. Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick Pope, and Paul Ganssle for reviews. --- tests/admin_widgets/tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/admin_widgets') diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index 1bb4c9a9b1..3a57227caa 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -4,7 +4,10 @@ import re from datetime import datetime, timedelta from importlib import import_module -import pytz +try: + import zoneinfo +except ImportError: + from backports import zoneinfo from django import forms from django.conf import settings @@ -967,8 +970,8 @@ class DateTimePickerShortcutsSeleniumTests(AdminWidgetSeleniumTestCase): error_margin = timedelta(seconds=10) # If we are neighbouring a DST, we add an hour of error margin. - tz = pytz.timezone('America/Chicago') - utc_now = datetime.now(pytz.utc) + tz = zoneinfo.ZoneInfo('America/Chicago') + utc_now = datetime.now(zoneinfo.ZoneInfo('UTC')) tz_yesterday = (utc_now - timedelta(days=1)).astimezone(tz).tzname() tz_tomorrow = (utc_now + timedelta(days=1)).astimezone(tz).tzname() if tz_yesterday != tz_tomorrow: -- cgit v1.3