chore(deps): replace pytest-freezegun with time-machine#962
Conversation
pytest-freezegun is unmaintained and generates 790 DeprecationWarnings on Python 3.12+ due to its use of distutils.version.LooseVersion. Replace it with time-machine, which is actively maintained and supports modern Python. Adapt tests to use @time_machine.travel decorator and an autouse fixture for class-level freezing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Thank you for supporting ScanAPI, and congratulations on your first contribution! A project committer will shortly review your contribution.
In the mean time, if you haven't had a chance please skim over the First Pull Request Guide which all pull requests must adhere to.
We hope to see you around!
camilamaia
left a comment
There was a problem hiding this comment.
Amazing!! 🎉
Could you also remove this line from the README.md?
Line 132 in 4289333
After your change, we don't have this restriction anymore, which is great.
Thanks!!
| "pytest>=9.0.3,<10.0.0", | ||
| "pytest-cov>=7.0.0,<8.0.0", | ||
| "pytest-freezegun==0.4.2", # Unmaintained; strict pin required for stability | ||
| "time-machine>=2.0,<3.0", |
There was a problem hiding this comment.
I've just noticed that the last stable version for time-machine is 3.2.0. Is there any specific reason to not pin the version range to something like >=3.0,<4.0 instead?
|
@klouds27 could you also please assign yourself to the issue you're working on? This helps avoid multiple people accidentally working on the same issue. It’s very simple: just comment |
Summary
pytest-freezegun(unmaintained since 2020, generates 790DeprecationWarnings on Python 3.12+ viadistutils.version.LooseVersion)time-machine>=2.0,<3.0as replacementtests/unit/test_reporter.pyandtests/unit/test_session.pyto the new APIMigration notes
@mark.freeze_time(...)on individual methods →@time_machine.travel(..., tick=False)decorator@mark.freeze_time(...)on a plain pytest class →autousefixture withtime_machine.travelcontext manager (class decorator only works onunittest.TestCasesubclasses)from freezegun.api import FakeDatetime→from datetime import datetime(time-machine uses real datetime objects)freezer.move_to(...)pattern →with time_machine.travel(...) as traveller: traveller.move_to(...)Test plan
uv sync --extra devinstallstime-machine==2.19.0and removespytest-freezegun/freezegunmake test→ 388 passed, 1 skipped, 0 warningsCloses #957
🤖 Generated with Claude Code