vendredi 28 décembre 2018

When testing time-dependent code in Python, how can I "speed up time" without skipping seconds?

Background

I'm currently working on a project for a company where they're trying to create software for managing those TV-screen-sized dynamic video ads that you see in malls.

As part of testing the software, I've learned how to use the freezegun package to run a test where the time is frozen at a particular value. I also see that it has an option to tick the time forward in chunks of seconds:

tick argument

FreezeGun has an additional tick argument which will restart time at the given value, but then time will keep ticking. This is alternative to the default parameters which will keep time stopped.

auto_tick_seconds argument

FreezeGun has an additional auto_tick_seconds argument which will autoincrement the value every time by the given amount from the start value. This is alternative to the default parameters which will keep time stopped. Note that given auto_tick_seconds the tick parameter will be ignored.


Problem

The problem with the above solution is that in order to test a full day of the billboard-management software I'm working on, I need both to dramatically speed up the rate of time and also keep the granularity of minutes and seconds, as there are some functions that need to execute seconds or minutes before other functions run.

How can I speed up time without just skipping time?

Aucun commentaire:

Enregistrer un commentaire