Skip to content

TST: add regression test for Timestamp(fold=..., tz=<str>) (GH-55932)#65422

Merged
mroeschke merged 3 commits into
pandas-dev:mainfrom
jbrockmendel:bug-55932
May 7, 2026
Merged

TST: add regression test for Timestamp(fold=..., tz=<str>) (GH-55932)#65422
mroeschke merged 3 commits into
pandas-dev:mainfrom
jbrockmendel:bug-55932

Conversation

@jbrockmendel

Copy link
Copy Markdown
Member

Summary

GH-55932 reports that the fold argument was ignored when tz was passed as a plain string (e.g. tz=\"US/Pacific\"), while dateutil.tz.gettz(...) and zoneinfo.ZoneInfo(...) worked. The string was resolving to a pytz zone, and pytz.localize ignores fold, so an AmbiguousTimeError was raised.

This was fixed as a side effect of GH-59089 (making pytz an optional dependency): maybe_get_tz now resolves a plain string to zoneinfo.ZoneInfo, which honors PEP 495 fold. This PR just adds a regression test to lock that behavior in — covering both reports in the issue thread (the year=/month=/... keyword form and the naive-datetime form).

Test plan

  • pytest pandas/tests/scalar/timestamp/test_constructors.py -k fold

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel marked this pull request as draft April 30, 2026 02:00
@jbrockmendel jbrockmendel marked this pull request as ready for review May 5, 2026 18:44
@jbrockmendel jbrockmendel added the Testing pandas testing functions or related to the test suite label May 7, 2026
@mroeschke mroeschke added this to the 3.1 milestone May 7, 2026
@mroeschke mroeschke merged commit 7a3ad0e into pandas-dev:main May 7, 2026
53 checks passed
@mroeschke

Copy link
Copy Markdown
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-55932 branch May 7, 2026 16:47
hamdanal pushed a commit to hamdanal/pandas that referenced this pull request Jun 27, 2026
…vGH-55932) (pandas-dev#65422)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Timestamp 'fold' argument ignored when tz is provided as string/name

2 participants