Add datetime/timedelta support to pytest.approx (#8395)#14414
Add datetime/timedelta support to pytest.approx (#8395)#14414hamza-mobeen wants to merge 5 commits intopytest-dev:mainfrom
Conversation
b4ef81a to
23e7a5e
Compare
Closes pytest-dev#8395 Co-authored-by: Antigravity <[email protected]>
2ea6f2f to
e720397
Compare
for more information, see https://pre-commit.ci
|
Hi @RonnyPfannschmidt , |
|
At first glance this looks good Im currently a bit stretched and hope to take a closer look next week |
no problem thanks. |
|
Hello @RonnyPfannschmidt I'm still waiting for your feedback. thanks |
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
overall this looks good
please check whats implemented in the base classes
please review our ai guidelines - i believe you are missing a few co-authored headers
|
|
||
| __hash__ = None | ||
|
|
||
| def __ne__(self, actual) -> bool: |
There was a problem hiding this comment.
this and a few more methods here seem to be copies from the base class
Co-authored-by: Codex <[email protected]>
Closes #8395
Description
This PR introduces native support for comparing
datetime.datetimeanddatetime.timedeltaobjects usingpytest.approx().Following the guidelines discussed in #8395:
abs) must be provided as adatetime.timedeltaobject. We intentionally avoid providing default tolerances as time comparisons lack sane defaults.rel) are not supported for time comparisons and will raise aTypeErrorwith an informative message.nan_okis also explicitly rejected for time comparisons.ApproxTimedeltaas an internal helper class to manage this specific comparison logic.testing/python/approx.pyensuring there are no regressions with existing numeric approximation behavior.Usage Example
Example Test Coverage
Checklist
closes #XYZWto the PR description and/or commits (whereXYZWis the issue number).Co-authored-bycommit trailers.changelogdirectory, with a name like<ISSUE NUMBER>.<TYPE>.rst.AUTHORSin alphabetical order.