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

Features

  • Freeze time in both the test and fixtures

  • Access the freezer when you need it

Installation

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

$ pip install pytest-freezegun

Usage

All the features can be seen in this example:

@pytest.fixture
def current_date():
    return datetime.now().date()

@pytest.mark.freeze_time('2017-05-21')
def test_current_date(current_date):
    assert current_date == date(2017, 5, 21)

@pytest.mark.freeze_time
def test_changing_date(current_date, freezer):
    freezer.move_to('2017-05-20')
    assert current_date == date(2017, 5, 20)
    freezer.move_to('2017-05-21')
    assert current_date == date(2017, 5, 21)

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

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

Issues

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

Credits

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

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-freezegun-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

pytest_freezegun-0.1.0-py2-none-any.whl (4.8 kB view details)

Uploaded Python 2

File details

Details for the file pytest-freezegun-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pytest-freezegun-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ce160dbc4299f10d686239b9d4a0af509226dd8fa8fa8055f4ffc53d758fa29
MD5 d6330ed77420764ed5e2db0c66d4fc5f
BLAKE2b-256 445314980e9ba18fbb9c3d6b43e793adfa5e61089c44479d1e5aeeb2332f6f25

See more details on using hashes here.

File details

Details for the file pytest_freezegun-0.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for pytest_freezegun-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 6cac13a948bfa9099f4744480c508a9a6f2a5f1c5a7cc7a86c9b7fc36475a157
MD5 a6981be49b821864464d2e6b5db3ecaa
BLAKE2b-256 bb3ff25c7e7fec5ba29f8945920ece050523b30a200a7b682fda11ae70bb64ab

See more details on using hashes here.

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