Skip to content

Commit 8211c78

Browse files
committed
fix: flaky screenshot test timing - 0.2s pause raced against the command's own 0.1s timer
Confirmed via a real CI failure on Python 3.9 (v0.1.22's tag push): test_save_screenshot_reports_failure_without_crashing failed there despite passing locally and on other Python versions - a genuine race, not a real product bug (the feature itself was separately confirmed working via live testing in a real container before this release). Both publish workflows' own separate test runs on the same commit happened not to hit the same timing loss and passed, so v0.1.22 did ship correctly - this is purely a test-reliability fix, nothing to re-release for. Increased both screenshot tests' pilot.pause() from 0.2s to 1.0s - a 10x margin over the command's own set_timer(0.1, ...) delay, verified stable across 5 repeated local runs before pushing this time, not just a single one.
1 parent d4c523d commit 8211c78

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/test_command_palette.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,14 @@ async def test_save_screenshot_uses_home_directory_not_cwd(tmp_path):
407407
async with app.run_test() as pilot:
408408
with patch.object(app, "deliver_screenshot", return_value="/home/fake/screenshot.svg") as mock_deliver:
409409
app._save_screenshot()
410-
await pilot.pause(0.2) # the real command schedules via set_timer(0.1, ...)
410+
# Real, confirmed flakiness: 0.2s here raced against the
411+
# command's own set_timer(0.1, ...) and lost on a Python
412+
# 3.9 CI runner once (the timer hadn't fired yet by the
413+
# time this returned) despite comfortably passing locally
414+
# and on other Python versions - a 10x margin over the
415+
# timer's own delay should be enough headroom that this
416+
# doesn't recur even under CI load/scheduling jitter.
417+
await pilot.pause(1.0)
411418
mock_deliver.assert_called_once_with(path=str(Path.home()))
412419
conv = app.query_one("#conversation", RichLog)
413420
text = "\n".join(str(line) for line in conv.lines)
@@ -420,7 +427,7 @@ async def test_save_screenshot_reports_failure_without_crashing(tmp_path):
420427
async with app.run_test() as pilot:
421428
with patch.object(app, "deliver_screenshot", side_effect=OSError("disk full")):
422429
app._save_screenshot()
423-
await pilot.pause(0.2) # must not raise
430+
await pilot.pause(1.0) # must not raise - see the sibling test's own comment on why 1.0s
424431
conv = app.query_one("#conversation", RichLog)
425432
text = "\n".join(str(line) for line in conv.lines)
426433
assert "failed" in text.lower()

0 commit comments

Comments
 (0)