From bebcf9584755aff4f3f5e5d8930930d6996bff9a Mon Sep 17 00:00:00 2001 From: Frowtek Date: Thu, 16 Jul 2026 19:12:41 +0300 Subject: [PATCH] test(delegate): assert copilot probe with assert_any_call to de-flake under slicing test_build_child_agent_ignores_acp_command_when_binary_missing patches shutil.which globally and asserted the LAST call was which("copilot"). That is order-dependent: an unrelated which("uv") reached later in the same process (which happens under some CI test-slice orderings) becomes the last call, so assert_called_with("copilot") fails even though the copilot binary was probed exactly as intended. Switch to assert_any_call("copilot"), which verifies the actual intent and is robust to unrelated which() calls. The behavioural assertions (provider, acp_command, acp_args) are unchanged. --- tests/tools/test_delegate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/tools/test_delegate.py b/tests/tools/test_delegate.py index 0fe6e0028eb..0ac285b5302 100644 --- a/tests/tools/test_delegate.py +++ b/tests/tools/test_delegate.py @@ -562,7 +562,11 @@ class TestToolNamePreservation(unittest.TestCase): captured["acp_command"] = kwargs.get("acp_command") captured["acp_args"] = kwargs.get("acp_args") - mock_which.assert_called_with("copilot") + # any_call, not called_with: the patch is global to shutil.which, so an + # unrelated which("uv") from a code path reached later in the same + # process (order-dependent under CI test-slicing) can be the *last* + # call. The intent here is only that the copilot binary was probed. + mock_which.assert_any_call("copilot") self.assertNotEqual( captured["provider"], "copilot-acp",