Control time in your tests by intercepting system time calls for testing time-dependent code
- Freeze time at a specific datetime or timestamp
- Advance time forward by seconds, minutes, hours, or days
- Rewind time backward for testing past scenarios
- Context manager for isolated time control within test scope
- Automatic restoration of real time after context exit
- Intercepts datetime.datetime.now() and datetime.datetime.utcnow()
- Intercepts time.time() and time.monotonic()
- Works with asyncio event loop time for async code
- Thread-safe time manipulation for concurrent tests
- No external dependencies - pure Python implementation
- Chainable API for fluent time manipulation
- Support for timezone-aware datetime objects
- Preserves microsecond precision in time values
Use this project when you need to:
- Quickly solve problems related to mock-clock
- Integrate python functionality into your workflow
- Learn how python handles common patterns
# Clone the repository
git clone https://github.com/KurtWeston/mock-clock.git
cd mock-clock
# Install dependencies
pip install -r requirements.txtpython main.py- python
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.