Skip to content

Commit fcc9ee5

Browse files
committed
TST: remove DST transition scenarios from tc #24689
1 parent 7c842b0 commit fcc9ee5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

pandas/tests/indexes/datetimes/test_timezones.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from distutils.version import LooseVersion
77

88
import dateutil
9-
from dateutil.tz import gettz, tzlocal
9+
from dateutil.tz import gettz, tzlocal, tzutc
1010
import numpy as np
1111
import pytest
1212
import pytz
@@ -434,24 +434,30 @@ def test_dti_tz_localize_utc_conversion(self, tz):
434434
with pytest.raises(pytz.NonExistentTimeError):
435435
rng.tz_localize(tz)
436436

437+
@pytest.mark.parametrize('tz', [
438+
'UTC', 'US/Eastern', 'Europe/London', 'Asia/Tokyo', 'Australia/NSW',
439+
'dateutil/US/Pacific', 'dateutil/Asia/Singapore', tzutc(),
440+
pytz.FixedOffset(300), pytz.FixedOffset(0), pytz.FixedOffset(-300)
441+
])
437442
@pytest.mark.parametrize('idx', [
438-
date_range(start='2014-01-01', end='2014-12-31', freq='M'),
439-
date_range(start='2014-01-01', end='2014-12-31', freq='D'),
440-
date_range(start='2014-01-01', end='2014-03-01', freq='H'),
441-
date_range(start='2014-08-01', end='2014-10-31', freq='T')
443+
date_range(start='2014-12-01', end='2015-02-28', freq='D'),
444+
date_range(start='2014-05-01', end='2015-07-31', freq='D'),
445+
date_range(start='2014-01-01', end='2014-02-28', freq='H'),
446+
date_range(start='2014-08-01', end='2014-09-30', freq='15T')
442447
])
443-
def test_dti_tz_localize_roundtrip(self, tz_aware_fixture, idx):
444-
tz = tz_aware_fixture
448+
def test_dti_tz_localize_roundtrip(self, tz, idx):
449+
# note: this tz tests that a tz-naive index can be localized
450+
# and de-localized successfully, when there are no DST transitions
451+
# in the range.
445452
localized = idx.tz_localize(tz)
446-
expected = date_range(start=idx[0], end=idx[-1], freq=idx.freq,
447-
tz=tz)
448-
tm.assert_index_equal(localized, expected)
453+
454+
# cant localize a tz-aware object
449455
with pytest.raises(TypeError):
450456
localized.tz_localize(tz)
451457

452458
reset = localized.tz_localize(None)
453-
tm.assert_index_equal(reset, idx)
454459
assert reset.tzinfo is None
460+
tm.assert_index_equal(reset, idx)
455461

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

0 commit comments

Comments
 (0)