Skip to content

Commit 14083f5

Browse files
committed
Move test from timezone to timestamp tests
Parametrize the unit test
1 parent 898897e commit 14083f5

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

pandas/tests/scalar/timestamp/test_timestamp.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,33 @@ def test_hash_equivalent(self):
432432
stamp = Timestamp(datetime(2011, 1, 1))
433433
assert d[stamp] == 5
434434

435+
@pytest.mark.parametrize(
436+
"timezone, year, month, day, hour",
437+
[["America/Chicago", 2013, 11, 3, 1], ["America/Santiago", 2021, 4, 3, 23]],
438+
)
439+
def test_hash_timestamp_with_fold(self, timezone, year, month, day, hour):
440+
# see gh-33931
441+
test_timezone = gettz(timezone)
442+
transition_1 = Timestamp(
443+
year=year,
444+
month=month,
445+
day=day,
446+
hour=hour,
447+
minute=0,
448+
fold=0,
449+
tzinfo=test_timezone,
450+
)
451+
transition_2 = Timestamp(
452+
year=year,
453+
month=month,
454+
day=day,
455+
hour=hour,
456+
minute=0,
457+
fold=1,
458+
tzinfo=test_timezone,
459+
)
460+
assert hash(transition_1) == hash(transition_2)
461+
435462
def test_tz_conversion_freq(self, tz_naive_fixture):
436463
# GH25241
437464
with tm.assert_produces_warning(FutureWarning, match="freq"):

pandas/tests/tslibs/test_timezones.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,3 @@ def test_maybe_get_tz_offset_only():
166166

167167
tz = timezones.maybe_get_tz("UTC-02:45")
168168
assert tz == timezone(-timedelta(hours=2, minutes=45))
169-
170-
171-
def test_hash_timestamp_with_fold():
172-
# see gh-33931
173-
america_chicago = dateutil.tz.gettz("America/Chicago")
174-
transition_1 = Timestamp(
175-
year=2013, month=11, day=3, hour=1, minute=0, tzinfo=america_chicago
176-
)
177-
transition_2 = Timestamp(
178-
year=2013, month=11, day=3, hour=1, minute=0, fold=1, tzinfo=america_chicago
179-
)
180-
assert hash(transition_1) == hash(transition_2)
181-
182-
america_santiago = dateutil.tz.gettz("America/Santiago")
183-
transition_3 = Timestamp(
184-
year=2021, month=4, day=3, hour=23, minute=0, tz=america_santiago
185-
)
186-
transition_4 = Timestamp(
187-
year=2021, month=4, day=3, hour=23, minute=0, fold=1, tz=america_santiago
188-
)
189-
assert hash(transition_3) == hash(transition_4)

0 commit comments

Comments
 (0)