Skip to content

gh-84649: Fix unstable test_rollover_at_midnight#151813

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:fix-test-rollover-at-midnight
Jun 20, 2026
Merged

gh-84649: Fix unstable test_rollover_at_midnight#151813
serhiy-storchaka merged 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>
@serhiy-storchaka serhiy-storchaka requested a review from vsajip as a code owner June 20, 2026 17:45
@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting core review labels Jun 20, 2026
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 20, 2026 17:58
@serhiy-storchaka serhiy-storchaka merged commit 1b9fe5c into python:main Jun 20, 2026
177 checks passed
@serhiy-storchaka serhiy-storchaka deleted the fix-test-rollover-at-midnight branch June 20, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant