From 2de8f5d122cbdc5af0804ed601d3b15bc43d63dc Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 22 Jun 2026 08:12:02 +0200 Subject: [PATCH] Fix non-hermetic diet_guard gate tests depending on a real X display test_demo_opens_window and test_bare_gate_due_opens_window never mocked wait_for_display(), so they silently relied on a real, reachable X display being present. On a dev machine this is always true, so they passed; on a true headless CI runner (no X server at all) each test blocked for the real 60s timeout before failing, explaining the CI run's 131s duration. Mocking it to True (matching the existing test_gate_due_but_display_not_ready_defers pattern for the False case) restores hermeticity with no production code change. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01A7vbgtFfZmfxJtN5DdtJky --- diet_guard/tests/test_cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diet_guard/tests/test_cli.py b/diet_guard/tests/test_cli.py index f2a5f16..c2fb9d3 100644 --- a/diet_guard/tests/test_cli.py +++ b/diet_guard/tests/test_cli.py @@ -229,6 +229,7 @@ class TestGate: patch.object(_cli, "MealGate", return_value=gate) as factory, patch.object(_cli, "acquire_gate_lock", return_value=MagicMock()), patch.object(_cli, "release_gate_lock"), + patch.object(_cli, "wait_for_display", return_value=True), ): assert main(["gate", "--demo"]) == 0 factory.assert_called_once_with(demo_mode=True) @@ -248,6 +249,7 @@ class TestGate: patch.object(_cli, "MealGate", return_value=gate), patch.object(_cli, "acquire_gate_lock", return_value=MagicMock()), patch.object(_cli, "release_gate_lock"), + patch.object(_cli, "wait_for_display", return_value=True), ): assert main(["gate"]) == 0 gate.run.assert_called_once()