Skip to content

Commit

Permalink
Use tz.gettz() instead of zoneinfo.gettz()
Browse files Browse the repository at this point in the history
zoneinfo.gettz() seems to have problems (1 & 2) on system which do not install
the zoninfo tarball (e.g. Debian, Gentoo and Fedora) but rely on the system
zoneinfo files. This results in test failures (3 & 4)
tz.gettz() doesn't suffer from this problem.

1 dateutil/dateutil#8
2 dateutil/dateutil#11
3 pandas-dev#9059
4 pandas-dev#8639

Signed-off-by: Justin Lecher <jlec@gentoo.org>
  • Loading branch information
jlec committed Dec 21, 2014
1 parent 0fe43a6 commit 2406642
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/test_series.py
Expand Up @@ -5021,7 +5021,7 @@ def test_getitem_setitem_datetime_tz_pytz(self):
def test_getitem_setitem_datetime_tz_dateutil(self):
tm._skip_if_no_dateutil();
from dateutil.tz import tzutc
from dateutil.zoneinfo import gettz
from dateutil.tz import gettz
tz = lambda x: tzutc() if x == 'UTC' else gettz(x) # handle special case for utc in dateutil

from pandas import date_range
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/tests/test_daterange.py
Expand Up @@ -441,7 +441,7 @@ def test_month_range_union_tz_pytz(self):
def test_month_range_union_tz_dateutil(self):
_skip_if_windows_python_3()
tm._skip_if_no_dateutil()
from dateutil.zoneinfo import gettz as timezone
from dateutil.tz import gettz as timezone
tz = timezone('US/Eastern')

early_start = datetime(2011, 1, 1)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_period.py
Expand Up @@ -104,12 +104,12 @@ def test_timestamp_tz_arg_dateutil(self):
import dateutil
from pandas.tslib import maybe_get_tz
p = Period('1/1/2005', freq='M').to_timestamp(tz=maybe_get_tz('dateutil/Europe/Brussels'))
self.assertEqual(p.tz, dateutil.zoneinfo.gettz('Europe/Brussels'))
self.assertEqual(p.tz, dateutil.tz.gettz('Europe/Brussels'))

def test_timestamp_tz_arg_dateutil_from_string(self):
import dateutil
p = Period('1/1/2005', freq='M').to_timestamp(tz='dateutil/Europe/Brussels')
self.assertEqual(p.tz, dateutil.zoneinfo.gettz('Europe/Brussels'))
self.assertEqual(p.tz, dateutil.tz.gettz('Europe/Brussels'))

def test_timestamp_nat_tz(self):
t = Period('NaT', freq='M').to_timestamp()
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/tests/test_timeseries.py
Expand Up @@ -419,7 +419,7 @@ def test_timestamp_to_datetime_explicit_dateutil(self):
tm._skip_if_no_dateutil()
import dateutil
rng = date_range('20090415', '20090519',
tz=dateutil.zoneinfo.gettz('US/Eastern'))
tz=dateutil.tz.gettz('US/Eastern'))

stamp = rng[0]
dtval = stamp.to_pydatetime()
Expand Down Expand Up @@ -1797,7 +1797,7 @@ def test_append_concat_tz_explicit_pytz(self):
def test_append_concat_tz_dateutil(self):
# GH 2938
tm._skip_if_no_dateutil()
from dateutil.zoneinfo import gettz as timezone
from dateutil.tz import gettz as timezone

rng = date_range('5/8/2012 1:45', periods=10, freq='5T',
tz='dateutil/US/Eastern')
Expand Down
2 changes: 1 addition & 1 deletion pandas/tslib.pyx
Expand Up @@ -41,7 +41,7 @@ from datetime import time as datetime_time
# dateutil compat
from dateutil.tz import (tzoffset, tzlocal as _dateutil_tzlocal, tzfile as _dateutil_tzfile,
tzutc as _dateutil_tzutc)
from dateutil.zoneinfo import gettz as _dateutil_gettz
from dateutil.tz import gettz as _dateutil_gettz

from pytz.tzinfo import BaseTzInfo as _pytz_BaseTzInfo
from pandas.compat import parse_date, string_types, PY3, iteritems
Expand Down

0 comments on commit 2406642

Please sign in to comment.