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.

Metadata

Release files for pytest-freezer 0.4.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-freezer 0.4.7
File Size Uploaded
pytest_freezer-0.4.7.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-freezer 0.4.7
File Interpreter ABI Platform
pytest_freezer-0.4.7-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / pytest_freezer-0.4.7.tar.gz

Download URL pytest_freezer-0.4.7.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f9241ae5547110558f90394d8a51e216d1247a31f3c2518b1a70082f355f4864
BLAKE2b-256 checksum
How to use checksums
1a06a28ba59bad74f0f5b9146524c81acbc99599a4ac7c8b118f2b8773df26c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / pytest_freezer-0.4.7-py3-none-any.whl

Download URL pytest_freezer-0.4.7-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4cb3dcf10d16c15b445be4a710c85b56aaa8110f6ee6ee7b88ab85c462023b1
BLAKE2b-256 checksum
How to use checksums
c8f05f51803ee9ad3afa7cb79af29573fca35112b1e94c00d1d67453f53257bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

0.4.9

2 release files

0.4.8

2 release files

This release

0.4.7 This release

2 release files

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page