{"id":941,"date":"2019-11-27T13:56:18","date_gmt":"2019-11-27T13:56:18","guid":{"rendered":"http:\/\/buklijas.info\/blog\/?p=941"},"modified":"2019-12-29T18:37:15","modified_gmt":"2019-12-29T18:37:15","slug":"941","status":"publish","type":"post","link":"http:\/\/buklijas.info\/blog\/2019\/11\/27\/941\/","title":{"rendered":"Mock time in Python unit tests"},"content":{"rendered":"
Published on:<\/strong> 27.11.2019<\/p>\n From my point of view, unit tests are useful, especially for refactoring functions that have clearly defined inputs and outputs.<\/p>\n One thing that is impossible to test is anything regarding time\/date code because whenever you run it is a different time \ud83d\ude42 .<\/p>\n 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<\/a> current time\/date.<\/p>\n