test_get_timezone_name fails in fixed-offset timezones
See original GitHub issueOverview Description
test_get_timezone_name seems to fail in fixed-offset timezones, such as Etc/GMT-7.
Steps to Reproduce
$ TZ=Etc/GMT-7 python -m pytest tests/test_dates.py
======================================= test session starts ========================================
platform linux2 -- Python 2.7.9, pytest-3.0.0, py-1.4.31, pluggy-0.3.1
rootdir: /home/jwilk/babel, inifile: setup.cfg
collected 68 items
tests/test_dates.py .......................................................F............
============================================= FAILURES =============================================
______________________________________ test_get_timezone_name ______________________________________
def test_get_timezone_name():
dt = time(15, 30, tzinfo=timezone('America/Los_Angeles'))
assert (dates.get_timezone_name(dt, locale='en_US') ==
u'Pacific Standard Time')
assert (dates.get_timezone_name(dt, locale='en_US', return_zone=True) ==
u'America/Los_Angeles')
assert dates.get_timezone_name(dt, width='short', locale='en_US') == u'PST'
tz = timezone('America/Los_Angeles')
assert dates.get_timezone_name(tz, locale='en_US') == u'Pacific Time'
assert dates.get_timezone_name(tz, 'short', locale='en_US') == u'PT'
tz = timezone('Europe/Berlin')
assert (dates.get_timezone_name(tz, locale='de_DE') ==
u'Mitteleurop\xe4ische Zeit')
assert (dates.get_timezone_name(tz, locale='pt_BR') ==
u'Hor\xe1rio da Europa Central')
tz = timezone('America/St_Johns')
assert dates.get_timezone_name(tz, locale='de_DE') == u'Neufundland-Zeit'
tz = timezone('America/Los_Angeles')
assert dates.get_timezone_name(tz, locale='en', width='short',
zone_variant='generic') == u'PT'
assert dates.get_timezone_name(tz, locale='en', width='short',
zone_variant='standard') == u'PST'
assert dates.get_timezone_name(tz, locale='en', width='short',
zone_variant='daylight') == u'PDT'
assert dates.get_timezone_name(tz, locale='en', width='long',
zone_variant='generic') == u'Pacific Time'
assert dates.get_timezone_name(tz, locale='en', width='long',
zone_variant='standard') == u'Pacific Standard Time'
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(localnow, locale='en_US'))
E assert 'GMT+00:00' == 'GMT+07:00'
E - GMT+00:00
E ? ^
E + GMT+07:00
E ? ^
tests/test_dates.py:628: AssertionError
====================================== pytest-warning summary ======================================
WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
====================== 1 failed, 67 passed, 1 pytest-warnings in 0.31 seconds =================
Additional Information
Tested with git master (5c02138363a0c0e1fbbfeccf2c6f5f731b6dee92), pytz==2016.6.1.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
FixedOffset in chrono::offset - Rust - Docs.rs
Makes a new FixedOffset for the Eastern Hemisphere with given timezone difference. The negative secs means the Western Hemisphere. Returns None on the...
Read more >Comparison between pytz and pandas timezones fails
I process the timestamps and convert to a timezone defined by the user, so that time shifts (DST) are handled correctly. As I...
Read more >Time and time zones - pvlib python - Read the Docs
Dealing with time and time zones can be a frustrating experience in any programming language and for any application. pvlib-python relies on pandas...
Read more >pd.date_range AssertionError: Inferred time zone not equal to ...
FixedOffset (120) and then raises an error because this is not the same as Europe/Berlin . When giving tz-aware datetimes with different UTC ......
Read more >Specify Time Zones - MATLAB & Simulink - MathWorks
You can specify a time zone when you create a datetime, using the 'TimeZone' name-value pair argument. The time zone value 'local' specifies...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@warsaw Okay, great! Closing this issue, but obviously do let us know if there’s anything we can do to make things easier for you folks 😃
@akx Thanks, and confirmed it does fix things for us in Ubuntu. We can’t update to 2.4.0 because we’re in beta freeze (and Debian is in freeze too), so I’ll just cherry pick the patch.