-
Mocking datetime in Python
2017-02-06 "It might be that pythonistas really don’t like monkey patching, but as I couldn’t find a quick answer on how to mock time in Python I thought I write down here how I did it.
It’s no big deal really, just replace datetime in the module tested with a local implementation. In my case I wanted to to mock
"datetime.utcnow
and to match the call I created a class withutcnow
as a static method.