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.
This commit is contained in:
Vito Sansevero
2026-10-26 18:30:22 -07:00
parent 99e5053e5c
commit b5017e4e01
+8 -2
View File
@@ -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)