Skip to main content

actions codecov pypi womm

pytest-freezer

Pytest plugin providing a fixture interface for freezegun.

Installation:

$ python -m pip install pytest-freezer

Usage:

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 = datetime.now()
    time.sleep(1)
    later = datetime.now()
    assert now == later

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

def test_freezer_methods(freezer):
    freezer.move_to("2022-10-17")
    assert datetime.now() == datetime(2022, 10, 17)
    freezer.tick()
    assert datetime.now() == datetime(2022, 10, 17, 0, 0, 1)
    freezer.tick(delta=12)
    assert datetime.now() == datetime(2022, 10, 17, 0, 0, 13)

Acknowledgements:

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

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.9.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_freezer-0.4.9-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_freezer-0.4.9.tar.gz.

File metadata

  • Download URL: pytest_freezer-0.4.9.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for pytest_freezer-0.4.9.tar.gz
Algorithm Hash digest
SHA256 21bf16bc9cc46bf98f94382c4b5c3c389be7056ff0be33029111ae11b3f1c82a
MD5 9a1183950d820d51d5e77548d009c542
BLAKE2b-256 81f098dcbc5324064360b19850b14c84cea9ca50785d921741dbfc442346e925

See more details on using hashes here.

File details

Details for the file pytest_freezer-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: pytest_freezer-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for pytest_freezer-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6c50523b7d4aec4590b52bfa5ff766d772ce506e2bf4846c88041ea9ccae59
MD5 389e999b2454b278963239e7d97940e4
BLAKE2b-256 c1e930252bc05bcf67200a17f4f0b4cc7598f0a68df4fa9fa356193aa899f145

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.9 This release

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

1 file

0.4.5

1 file

0.4.4

1 file

0.4.3

1 file

0.4.2

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page