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)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_freezer-0.4.8.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|