freeze_time
Context manager to temporarily freeze time.time(). This temporarily modifies the time function of the time module. Modules which import the time function directly (e.g. from time import time) won't be affected This isn't meant as a public API, but helps reduce some repetitive code in Django's test suite.
def freeze_time(
t: float
) - > Generator
Context manager to temporarily freeze time.time(). This temporarily modifies the time function of the time module. Modules which import the time function directly (e.g. from time import time) won't be affected This isn't meant as a public API, but helps reduce some repetitive code in Django's test suite.
Parameters
| Name | Type | Description |
|---|---|---|
| t | float | The fixed Unix timestamp that time.time() should return during the duration of the context manager. |
Returns
| Type | Description |
|---|---|
Generator | A context manager that yields control while the system time is mocked, then restores the original time function upon exit. |