GH-31318: [Python] Add fixed-offset timezones to Hypothesis test strategy#49844
GH-31318: [Python] Add fixed-offset timezones to Hypothesis test strategy#49844alex-anast wants to merge 3 commits intoapache:mainfrom
Conversation
|
|
|
|
|
@github-actions crossbow submit test-conda-python-3.11-hypothesis |
|
Revision: 6c9a20e Submitted crossbow builds: ursacomputing/crossbow @ actions-16091e66e1
|
|
The extended hypothesis failure is currently unrelated, opened an issue for it here: #49846 |
AlenkaF
left a comment
There was a problem hiding this comment.
Thanks for the PR!
The only comment I have for now is that the current strategy can produce UTC out of the valid UTC range which is UTC-12 and UTC+14, for example UTC-12:45. Datetime will accept it but as this is invalid IANA timezone it should be improved, it also might produce errors in other parts.
|
|
2 similar comments
|
|
|
|
|
@AlenkaF thanks for the review! edit: on hindsight, a lower bound filter is unnecessary since the lower bound can never be violated -- harmless, clear and defensive, but dead code. |
|
Thanks for the update! There is a PR up to fix the hypothesis build: #49847. After that is merged you can rebase and we can run the build here, to double check the logic. |
|
@alex-anast the PR has been merged on main, if you could rebase I'll re-trigger the hypothesis tests on CI |
564317e to
820665d
Compare
|
@github-actions crossbow submit test-conda-python-3.11-hypothesis |
|
expected 😓 @raulcd can you please re-trigger the test when you get the chance? |
|
@github-actions crossbow submit test-conda-python-3.11-hypothesis |
|
Revision: 820665d Submitted crossbow builds: ursacomputing/crossbow @ actions-096afcf5c0
|
|
I think the failure is connected to the changes in this PR: TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'datetime.timedelta' |
Rationale for this change
The Hypothesis test strategy for timezones (
pyarrow.tests.strategies.timezones) only generates named IANA timezones (via pytz and zoneinfo). It does not generate fixed-offset timezones like+05:30or-03:00. As noted in #31318, this is not supported out of the box by Hypothesis, so a custom strategy is needed. Fixed-offset timezones are already used in manual tests and handled correctly by Arrow, but are never exercised via property-based testing.What changes are included in this PR?
Adds a
fixed_offset_timezonesstrategy topython/pyarrow/tests/strategies.pythat generatesdatetime.timezoneobjects with offsets ranging from UTC-12:00 to UTC+14:00, with minute components of 0, 30, or 45 (covering all real-world UTC offsets). This strategy is included in the existingtimezonesstrategy across all dependency configurations.Are these changes tested?
This change improves test infrastructure itself -- it extends the
timezonesstrategy used by existing Hypothesis-based tests. The generated fixed-offset timezones were verified to work correctly withpa.timestamp().The test command used was:
Are there any user-facing changes?
No. This only affects the internal test suite.
AI-generated code disclosure
This PR was developed with assistance from an AI coding tool (Claude, Anthropic). All changes have been reviewed, understood, and verified.
Closes [Python] Update timezones strategy to include fixed offsets #31318