FreezeFrog lets you mock datetimes in tests.
(Interested in working on projects like this? Close.io is looking for great engineers to join our team.)
Why FreezeFrog?
FreezeFrog is a Python library that lets you mock datetimes in tests. Its goal is to be simple and fast.
In comparison to certain other time freezing libraries, FreezeFrog doesn’t loop through all imported modules, making it fast even for larger projects.
FreezeFrog currently supports mocking the following basic methods:
datetime.datetime.now
datetime.datetime.utcnow
time.time
FreezeFrog supports both datetime and pytz timezone objects.
Usage
Use the FreezeTime context manager to freeze the time. Pass the desired datetime object to the constructor, and the timezone to mock the system’s timezone (defaults to datetime.timzone.utc). The constructor also takes the fold argument (0 by default), which defines whether an ambiguous time refers to its first or second appearance, and the tick argument (False by default), which makes the clock start ticking.
import datetime
from freezefrog import FreezeTime
with FreezeTime(datetime.datetime(2014, 1, 1)):
# The clock is frozen.
# Always prints 2014-01-01 00:00:00
print(datetime.datetime.utcnow())
with FreezeTime(datetime.datetime(2014, 1, 1), tick=True):
# The clock starts ticking immediately.
# Example output: 2014-01-01 00:00:00.000005
print(datetime.datetime.utcnow())
Metadata
Release files for freezefrog 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| freezefrog-0.4.1.tar.gz | 3.8 kB | Without provenance | Details |
Release files / freezefrog-0.4.1.tar.gz
| Download URL | freezefrog-0.4.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b35f6eb17bd79351d74f8536458090a79fde4d5af8de067816c1653b026fb752
|
|
BLAKE2b-256 checksum How to use checksums |
3f97f82c0c65ffdee26955c0ed11b190d32c90a49a0bc999d97511db766f82c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9
|
Security for freezefrog 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.