skillfed

pytest-freezer

Pytest plugin providing a fixture interface for spulec/freezegun

pytest-freezer v0.4.9 1.4M downloads/30d#3,979 on PyPI57
Permissive license DORMANT released

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-freezer

uv

uv add pytest-freezer

poetry

poetry add pytest-freezer

Installing 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

Framework :: PytestLicense :: OSI Approved :: MIT License

Tags

pytest time mockingfreeze time in testspytest datetime fixturetest time controlfreezegun pytest pluginmock system clockdeterministic time testing
testing-fixturetime-mocking

More Testing packages