From b5017e4e017226b2d2be2fdbd99de9e7e3cc194f Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Mon, 26 Oct 2026 18:30:22 -0700 Subject: [PATCH] test(images): hold the listing clock in the deferred-walk test test_a_deferred_walk_waits_at_least_half_a_second set the previous walk 29.99 s back against a 30 s interval and then read the real clock again: a runner slower than 10 ms between the two lines passed the interval and the walk started at once (failed on macOS 3.13 and Windows 3.11). The module's clock is now held for the mark, so the deferred walk is always the one measured. --- tests/test_api_images.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_api_images.py b/tests/test_api_images.py index b0b9e353..5b0fa3e3 100644 --- a/tests/test_api_images.py +++ b/tests/test_api_images.py @@ -12,6 +12,7 @@ import pathlib import sys import tempfile import threading +import types import unittest from contextlib import ExitStack from pathlib import Path, PurePath @@ -3459,8 +3460,13 @@ class TestSharedListing(ImageAPITestCase): record = await self._listed() self._interval(30) # The interval ends in a few milliseconds: still never a zero delay. - record.last_started_at = images_module._time.monotonic() - 29.99 - self.api.mark_root_dirty(self._output("b.png")) + # The module's clock is held, so a slow runner cannot pass the end + # of the interval between these lines (the walk would start at once). + now = images_module._time.monotonic() + record.last_started_at = now - 29.99 + held = types.SimpleNamespace(monotonic=lambda: now) + with patch.object(images_module, "_time", held): + self.api.mark_root_dirty(self._output("b.png")) handle = record.rewalk_handle self.assertIsNotNone(handle) self.assertGreaterEqual(self._remaining(handle), 0.45)