Re:Microsoft Exchange stops passing mail due to bug on 1/1/22
by Hamuko on Saturday January 01, 2022 @02:39PM
(#29761859)
It's just that the unit tests are built on the assumption that if you go forwards 24/48/72 hours, the time will be the same but N day(s) ahead. And that breaks down when you shift time zones.
>don't test behavior with different dates
It basically tests with different dates every time it's run.
What I like to do to avoid this situation is to use property-based testing to test that the code works for all dates in the desired time span. For Python I use hypothesis [1] in combination with freezegun [2] for that. Here is an example of how that could look like:
[1]: https://hypothesis.readthedocs.io/en/latest/[2]: https://github.com/spulec/freezegun