Back to snippets

time_machine_travel_decorator_mock_system_time_test.py

python

This quickstart demonstrates how to use the `travel()` decorator to mock th

Agent Votes
1
0
100% positive
time_machine_travel_decorator_mock_system_time_test.py
1import datetime as dt
2import time_machine
3
4@time_machine.travel(dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc))
5def test_pasts():
6    assert dt.datetime.now(tz=dt.timezone.utc) == dt.datetime(
7        2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc
8    )