◐ Shell
clean mode source ↗

gh-84649: Fix unstable test_rollover_at_midnight by serhiy-storchaka · Pull Request #151813 · python/cpython

The test test_rollover_at_midnight (and test_rollover_at_weekday) became unstable on Windows after gh-84649, which made TimedRotatingFileHandler base the rollover time on the minimum of the file creation and modification times. The test forced a rollover by back-dating the modification time, but the creation time cannot be changed, so the file no longer reliably looked old enough and the rollover did not happen.

Instead of moving the file's timestamps into the past, set the rollover time (atTime) one second after the file creation time and wait until the clock reaches it. This keeps the one-second offset that exercises the atTime rounding in computeRollover() while no longer depending on the ability to change the file times.