Skip to content

Commit

Permalink
TST: remove DST transition scenarios from test_dti_tz_localize_roundt…
Browse files Browse the repository at this point in the history
  • Loading branch information
robbuckley committed Jan 23, 2019
1 parent 7c842b0 commit 76f8808
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from distutils.version import LooseVersion

import dateutil
from dateutil.tz import gettz, tzlocal
from dateutil.tz import gettz, tzlocal, tzutc
import numpy as np
import pytest
import pytz
Expand Down Expand Up @@ -434,24 +434,30 @@ def test_dti_tz_localize_utc_conversion(self, tz):
with pytest.raises(pytz.NonExistentTimeError):
rng.tz_localize(tz)

@pytest.mark.parametrize('tz', [
'UTC', 'US/Eastern', 'Europe/London', 'Asia/Tokyo', 'Australia/NSW',
'dateutil/US/Pacific', 'dateutil/Asia/Singapore', tzutc(),
pytz.FixedOffset(300), pytz.FixedOffset(0), pytz.FixedOffset(-300)
])
@pytest.mark.parametrize('idx', [
date_range(start='2014-01-01', end='2014-12-31', freq='M'),
date_range(start='2014-01-01', end='2014-12-31', freq='D'),
date_range(start='2014-01-01', end='2014-03-01', freq='H'),
date_range(start='2014-08-01', end='2014-10-31', freq='T')
date_range(start='2014-12-01', end='2015-02-28', freq='D'),
date_range(start='2014-05-01', end='2015-07-31', freq='D'),
date_range(start='2014-01-01', end='2014-02-28', freq='H'),
date_range(start='2014-08-01', end='2014-09-30', freq='15T')
])
def test_dti_tz_localize_roundtrip(self, tz_aware_fixture, idx):
tz = tz_aware_fixture
def test_dti_tz_localize_roundtrip(self, tz, idx):
# note: this tz tests that a tz-naive index can be localized
# and de-localized successfully, when there are no DST transitions
# in the range.
localized = idx.tz_localize(tz)
expected = date_range(start=idx[0], end=idx[-1], freq=idx.freq,
tz=tz)
tm.assert_index_equal(localized, expected)

# cant localize a tz-aware object
with pytest.raises(TypeError):
localized.tz_localize(tz)

reset = localized.tz_localize(None)
tm.assert_index_equal(reset, idx)
assert reset.tzinfo is None
tm.assert_index_equal(reset, idx)

def test_dti_tz_localize_naive(self):
rng = date_range('1/1/2011', periods=100, freq='H')
Expand Down

0 comments on commit 76f8808

Please sign in to comment.