]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix the way local time is constructed in tests 411/head
authorIsaac Jurado <diptongo@gmail.com>
Sun, 29 May 2016 08:50:42 +0000 (10:50 +0200)
committerIsaac Jurado <diptongo@gmail.com>
Sun, 29 May 2016 09:37:55 +0000 (11:37 +0200)
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.

tests/test_dates.py

index 3bb9e8b227f3edbf54f8cb4ee3ec530116a79e28..b0d093ec2805bcad0ddb36990883a962cee95c6f 100644 (file)
@@ -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")