Skip to main content

Pytest plugin providing a fixture interface for spulec/freezegun

Project description

actions codecov pypi womm


Pytest plugin providing a fixture interface for freezegun.


$ python -m pip install pytest-freezer


The fixture name is freezer. It is a freezegun.api.FrozenDateTimeFactory instance, so refer to upstream freezegun usage for the methods .

Time is frozen by default when the fixture is injected:

def test_frozen_date(freezer):
    now =
    later =
    assert now == later

Time can be controlled within a test by using methods on the fixture:

def test_freezer_methods(freezer):
    assert == datetime(2022, 10, 17)
    assert == datetime(2022, 10, 17, 0, 0, 1)
    assert == datetime(2022, 10, 17, 0, 0, 13)


Credit to Tomasz Kontusz for the original pytest-freezegun plugin.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_freezer-0.4.4.tar.gz (6.5 MB view hashes)

Uploaded Source

Built Distribution

pytest_freezer-0.4.4-py2.py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page