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.
This commit is contained in:
Frowtek 2026-07-16 19:12:41 +03:00 • committed by Teknium
parent 7ada946436
commit bebcf95847

View file

@ -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",