From my point of view, unit tests are useful, especially for refactoring functions that have clearly defined inputs and outputs.

One thing that is impossible to test is anything regarding time/date code because whenever you run it is a different time 🙂 .

For example, if you have a function that calculates the number of days between two dates, the only way to test is to somehow mock current time/date.

in Python, there is FreezeGun.

It is implemented as a decorator, which is handy and readable in code.

So far I have not found any problem with FreezeGun.

Start a Conversation

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.