Fake the time.sleep/asyncio.sleep function during tests.
Project description
💤 SleepFake: Time Travel for Your Tests
Ever wish your tests could skip the wait? SleepFake lets you fake time.sleep and asyncio.sleep so your tests run at lightning speed—no more wasting time waiting for the clock!
🚀 Features
- Instantly skip over
sleepcalls in both sync and async code - Works with
time.sleepandasyncio.sleep - Compatible with pytest and pytest-asyncio
- Supports context manager and async context manager usage
- No more slow tests—get results fast!
✨ Example Usage
from sleepfake import SleepFake
import time
import asyncio
# Synchronous example
with SleepFake():
start = time.time()
time.sleep(10) # Instantly skipped!
end = time.time()
print(f"Elapsed: {end - start:.2f}s") # Elapsed: 10.00s
# Asynchronous example
async def main():
async with SleepFake():
start = asyncio.get_event_loop().time()
await asyncio.sleep(5) # Instantly skipped!
end = asyncio.get_event_loop().time()
print(f"Elapsed: {end - start:.2f}s") # Elapsed: 5.00s
asyncio.run(main())
🧪 Why Use SleepFake?
- Speed up your test suite: No more real waiting!
- Test time-based logic: Simulate long waits, retries, and timeouts instantly.
- Fun to use: Who doesn't love time travel?
📦 Installation
pip install sleepfake
🤝 Contributing
PRs and issues welcome! Help make testing even more fun.
Made with ❤️ and a dash of impatience.
Note: SleepFake uses freezegun under the hood for time manipulation magic.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sleepfake-1.1.2.tar.gz.
File metadata
- Download URL: sleepfake-1.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3911475bfbe87ec6349ff4006dc030f69cea6ef755da0c80834c5a4cccc9d11d
|
|
| MD5 |
43f68da391b3b6edc6d559bcf2723689
|
|
| BLAKE2b-256 |
1ae638f7500d17ccbb2ae6404d65b29cbcc324bfa93ff1ca3623dfd1069b93d2
|
Provenance
The following attestation bundles were made for sleepfake-1.1.2.tar.gz:
Publisher:
release.yml on Guiforge/sleepfake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sleepfake-1.1.2.tar.gz -
Subject digest:
3911475bfbe87ec6349ff4006dc030f69cea6ef755da0c80834c5a4cccc9d11d - Sigstore transparency entry: 273874078
- Sigstore integration time:
-
Permalink:
Guiforge/sleepfake@4586cce65b65d316ba8f3974265989ce9961c570 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/Guiforge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4586cce65b65d316ba8f3974265989ce9961c570 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sleepfake-1.1.2-py3-none-any.whl.
File metadata
- Download URL: sleepfake-1.1.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
886411d93b413ef39976c84d4f1e110ed301ac94cdcec7ccb3d9e4715eaaa148
|
|
| MD5 |
3fef7ea905d160c9ab8026dbfd862e91
|
|
| BLAKE2b-256 |
6be9ca799ff2d6d127462f9e011de7dbe0488c48f5e1493a836f1438ab312679
|
Provenance
The following attestation bundles were made for sleepfake-1.1.2-py3-none-any.whl:
Publisher:
release.yml on Guiforge/sleepfake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sleepfake-1.1.2-py3-none-any.whl -
Subject digest:
886411d93b413ef39976c84d4f1e110ed301ac94cdcec7ccb3d9e4715eaaa148 - Sigstore transparency entry: 273874079
- Sigstore integration time:
-
Permalink:
Guiforge/sleepfake@4586cce65b65d316ba8f3974265989ce9961c570 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/Guiforge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4586cce65b65d316ba8f3974265989ce9961c570 -
Trigger Event:
release
-
Statement type: