Skip to content

Commit 83fa7ba

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
datetime does not work with non-constant pytz.timezone
This has always been the case (and is explicitly warned about in the pytz documentation), but became a test fail when tzdata 2024b changed 'CET' and similar to aliases. Author: Rebecca N. Palmer <[email protected]> Forwarded: no Gbp-Pq: Name no_pytz_datetime.patch
1 parent ff35c3d commit 83fa7ba

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pandas/tests/arrays/test_array.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ def test_array_copy():
272272
assert tm.shares_memory(a, b)
273273

274274

275-
cet = pytz.timezone("CET")
275+
cetfixed = pytz.timezone("Etc/GMT-1") # the wrong-looking sign is because Etc/* use posix convention, as described in the tzdata source
276+
cetwithdst = pytz.timezone("Europe/Brussels")
276277

277278

278279
@pytest.mark.parametrize(
@@ -313,11 +314,20 @@ def test_array_copy():
313314
),
314315
(
315316
[
316-
datetime.datetime(2000, 1, 1, tzinfo=cet),
317-
datetime.datetime(2001, 1, 1, tzinfo=cet),
317+
datetime.datetime(2000, 1, 1, tzinfo=cetfixed),
318+
datetime.datetime(2001, 1, 1, tzinfo=cetfixed),
318319
],
319320
DatetimeArray._from_sequence(
320-
["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cet, unit="ns")
321+
["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cetfixed, unit="ns")
322+
),
323+
),
324+
(
325+
[
326+
cetwithdst.localize(datetime.datetime(2000, 1, 1)),
327+
cetwithdst.localize(datetime.datetime(2001, 1, 1)),
328+
],
329+
DatetimeArray._from_sequence(
330+
["2000", "2001"], dtype=pd.DatetimeTZDtype(tz=cetwithdst, unit="ns")
321331
),
322332
),
323333
# timedelta

0 commit comments

Comments
 (0)