--- id: pytest-freezegun version: "0.4.2" license: MIT license_treatment: permissive maintenance: abandoned --- # pytest-freezegun — Wrap tests with fixtures in freeze_time License: permissive · Maintenance: abandoned · Downloads: 1.4M/mo ## What it is and what it does pytest-freezegun is a pytest plugin that integrates freezegun's time-freezing capability into the pytest testing framework. It provides a `freezer` fixture that you can inject into test functions to freeze and manipulate the system clock, and a `@pytest.mark.freeze_time` decorator for marking tests that should run with time frozen. This is useful when testing code that depends on the current date or time—you can freeze time at a specific moment, advance it, or move to a different date entirely, all within a single test, ensuring reproducible and deterministic behavior. The plugin works with both function-based and class-based tests, integrates with other fixtures, and allows you to pass arguments to freezegun via the decorator. Because it depends on freezegun and pytest, you need both installed. The package is no longer actively maintained, with the last release in 2020 and no updates since then, so it may have compatibility issues with recent versions of pytest or Python. Use it for: - Test code that checks if a deadline has passed by freezing time at a specific date and asserting the expected behavior. - Verify that scheduled tasks trigger correctly by advancing frozen time and checking task execution. - Test time-dependent calculations (e.g., age, interest accrual) by setting the clock to known dates. - Ensure that retry logic with exponential backoff works as expected by controlling time progression. - Test timezone-aware datetime handling by freezing time at specific moments across different zones. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. pytest-freezegun provides a pytest plugin that freezes time in tests using freezegun, allowing you to control the system clock within test functions and fixtures. Yes, if your project is on a stable pytest and Python version and you need straightforward time-freezing in tests. No, if you require active maintenance or compatibility with recent pytest/Python releases—the package is abandoned and may break with newer versions. Consider it a low-risk, low-friction addition to an established test suite, but not a foundation for new projects expecting long-term support. ## Install pip install pytest-freezegun uv add pytest-freezegun poetry add pytest-freezegun ## Installing pytest-freezegun Before you install: Low install friction with only two runtime dependencies (freezegun and pytest). However, the package is abandoned—last release was 2020-07-19 and last commit 2023-03-28—so it will not receive bug fixes or updates for newer Python or pytest versions. License in practice: MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions, though you must include the license notice. Quickstart: pip install pytest-freezegun import pytest from datetime import datetime def test_frozen_date(freezer): now = datetime.now() freezer.move_to('2017-05-20') later = datetime.now() assert now != later Verify before relying: - Whether the package works reliably with pytest versions released after 2020-07-19 - Compatibility with Python versions beyond 3.8 (classifiers list only up to 3.8) ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest time freezing, mock time in tests, freeze time pytest fixture, control system clock tests, datetime mocking pytest, time travel testing, freezegun pytest plugin, pytest-plugin, time-mocking, test-fixtures [View on SkillFed](https://skillfed.io/packages/pytest-freezegun) · [View on PyPI](https://pypi.org/project/pytest-freezegun/)