pytest-freezer
Pytest plugin providing a fixture interface for spulec/freezegun
What it is and what it does
pytest-freezer wraps freezegun as a pytest fixture, letting you freeze and manipulate system time within test functions. Instead of manually managing freezegun contexts, you inject the `freezer` fixture into your test and call methods like `move_to()` and `tick()` to advance or set the clock. Time is frozen by default when the fixture is active, so datetime calls return consistent values across a test—useful for testing time-sensitive logic without waiting for real time to pass or dealing with flaky tests that depend on wall-clock timing.
The package depends on pytest and freezegun, both of which are widely used in the Python ecosystem. It requires Python 3.6 or later and is classified as a testing framework plugin. With low install friction and no known vulnerabilities, it is a straightforward addition to test suites that need deterministic time control.
Use it for:
- Test code that checks expiration dates or time-based conditions without waiting for real time to elapse
- Verify scheduled task or cron-like behavior by advancing the clock to specific dates and times
- Ensure datetime-dependent calculations produce consistent results across test runs
- Test retry logic or timeout behavior by controlling how much time passes between operations
- Validate time-zone-aware datetime handling in isolation from the system clock
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pytest-freezer provides a pytest fixture that freezes system time during tests, allowing you to control the clock for reproducible time-dependent test scenarios.
Yes. If your test suite includes time-dependent code, pytest-freezer eliminates the friction of managing freezegun contexts manually. The fixture interface is cleaner than raw freezegun, install friction is minimal, and the MIT license poses no restrictions. Maintenance is dormant but the package is stable and narrow in scope—there is little that can break. Install it when you need time control in pytest tests.
Install
pytest-freezer on PyPI
pip
pip install pytest-freezeruv
uv add pytest-freezerpoetry
poetry add pytest-freezerInstalling pytest-freezer
Before you install
Low friction installation as a pure-Python wheel. Maintenance is dormant—the last release was 610 days ago—but the repository remains active and the package is stable enough for its narrow use case.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install pytest-freezer
import pytest
from datetime import datetime
def test_frozen_date(freezer):
now = datetime.now()
freezer.move_to("2022-10-17")
assert datetime.now().date().isoformat() == "2022-10-17"
Verify before relying
- Whether the package actively addresses pytest or freezegun API changes in newer releases
- Compatibility with pytest versions beyond the current major release
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pytest, freezegun |
| Maintenance | dormant — 610 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,383,989/month — #3,979 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_freezer-0.4.9-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
Frozen-FlaskConverts a Flask application into a directory…
permissive · top 15,000 on PyPI
pytest-freezegunpytest-freezegun provides a pytest plugin that…
permissive · top 5,000 on PyPI
time-machineMocks and freezes time in tests, allowing you…
permissive · top 1,000 on PyPI
freezegunFreezeGun mocks Python's datetime and time…
permissive · top 1,000 on PyPI
pytest-pgsqlA pytest plugin that provides fixtures for…
permissive · top 15,000 on PyPI
looptimeLooptime fakes the passage of time in asyncio…
permissive · top 15,000 on PyPI
pytest-httpbinProvides a pytest fixture that runs a local…
permissive · top 15,000 on PyPI
pytest-rngProvides pytest fixtures that make random…
permissive · top 15,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,000 on PyPI
pytest-durationsA pytest plugin that measures and reports…
permissive · top 5,000 on PyPI