Just discovered that there's another time mocking library for python apart from freezegun: time-machine.

https://adamj.eu/tech/2020/06/03/introducing-time-machine/

I found out this solely because freezegun gave a "DeprecationWarning: datetime.utcfromtimestamp() is deprecated" on python 3.12 and read from this https://github.com/spulec/freezegun/pull/511 that people have been switching to time-machine.

The time-machine seems to work well. It also claims to give speed improvements.

#python #testing #pytest #pythontesting

Introducing time-machine, a New Python Library for Mocking the Current Time - Adam Johnson

Whilst writing Speed Up Your Django Tests, I wanted to add a section about mocking the current time. I knew of two libraries for such mocking, but I found it hard to pick one to recommend due to the trade-offs in each. So I delayed adding that section and shaved a rather large yak by writing a third library.