Skip to content

gh-84649: Fix unstable test_rollover_at_midnight#151813

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:fix-test-rollover-at-midnight
Open

gh-84649: Fix unstable test_rollover_at_midnight#151813
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:fix-test-rollover-at-midnight

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

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.

The test forced a rollover by back-dating the file modification time, but
the rollover time is now based also on the creation time, which cannot be
changed.  Instead, set the rollover time one second after the file
creation time and wait until the clock reaches it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant