From: Isaac Jurado Date: Sun, 29 May 2016 08:50:42 +0000 (+0200) Subject: Fix the way local time is constructed in tests X-Git-Tag: v2.4.0~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=476515c2418039e471656f47efbfc43e5230c1fd;p=thirdparty%2Fbabel.git Fix the way local time is constructed in tests In summer time zones, the test for "get_timezone_name" failed because the construct used to obtain a local time did not deal properly with DST offsets. As recommended by pytz, it is better to convert to local time from UTC. --- diff --git a/tests/test_dates.py b/tests/test_dates.py index 3bb9e8b2..b0d093ec 100644 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -624,8 +624,9 @@ def test_get_timezone_name(): assert dates.get_timezone_name(tz, locale='en', width='long', zone_variant='daylight') == u'Pacific Daylight Time' + localnow = datetime.utcnow().replace(tzinfo=timezone('UTC')).astimezone(dates.LOCALTZ) assert (dates.get_timezone_name(None, locale='en_US') == - dates.get_timezone_name(datetime.now().replace(tzinfo=dates.LOCALTZ), locale='en_US')) + dates.get_timezone_name(localnow, locale='en_US')) assert (dates.get_timezone_name('Europe/Berlin', locale='en_US') == "Central European Time")