11 hours ago · Tech · hide · 0 comments

Python A-Z is a blog series about Python. Each day, I share insights, ideas and examples for different parts of Python development that match with the letter of the day. Blaugust is an annual blogging festival in August where the goal is to write a blog post every day of the month. Quite a lot of our software has code in it that deals with time: either by displaying some time (current time, creation/modification time, countdowns etc.) or by doing different logic based on the current time (”show this for the week leading into Christmas” type of deal). Time is wibbly wobbly — as my favourite Doctor would say — and when writing tests, it means that we need tools to control time. If we let tests run against the system clock, they will fail sometimes and succeed other times. That doesn’t make them very good tests. Adam Johnson’s time-machine is a lovely library with a great logo to do exactly that (and fast as well). The interface is nice and simple. A decorator lets you travel to a…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.