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.8

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.8
File Size Uploaded
pytest_freezer-0.4.8.tar.gz 3.2 kB Details

Built distribution (wheel)

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

Total release size: 6.4 kB

Release files / pytest_freezer-0.4.8.tar.gz

Download URL pytest_freezer-0.4.8.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8ee2f724b3ff3540523fa355958a22e6f4c1c819928b78a7a183ae4248ce6ee6
BLAKE2b-256 checksum
How to use checksums
69faa93d40dd50f712c276a5a15f9c075bee932cc4d28c376e60b4a35904976d
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.8-py3-none-any.whl

Download URL pytest_freezer-0.4.8-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
644ce7ddb8ba52b92a1df0a80a699bad2b93514c55cf92e9f2517b68ebe74814
BLAKE2b-256 checksum
How to use checksums
d84eba488639516a341810aeaeb4b32b70abb0923e53f7c4d14d673dc114d35a
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

This release

0.4.8 This release

2 release files

0.4.7

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