Skip to main content

Wrap tests with fixtures in freeze_time

Project description

See Build Status on Travis CI See Build Status on AppVeyor

Wrap tests with fixtures in freeze_time


  • Freeze time in both the test and fixtures

  • Access the freezer when you need it


You can install “pytest-freezegun” via pip from PyPI:

$ pip install pytest-freezegun


All the features can be seen in this example:

def current_date():

def test_current_date(current_date):
    assert current_date == date(2017, 5, 21)

def test_changing_date(current_date, freezer):
    assert current_date == date(2017, 5, 20)
    assert current_date == date(2017, 5, 21)

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


Contributions are very welcome. Tests can be run with tox. You can later check coverage with coverage combine && coverage html. Please try to keep coverage at least the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-freezegun” is free and open source software


If you encounter any problems, please file an issue along with a detailed description.


This Pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

pytest_freezegun-0.3.0-py3-none-any.whl (4.0 kB view hashes)

Uploaded py3

Supported by

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