From f43ff5b4bbd3df2c703ddd2d180fb76ee0232dba Mon Sep 17 00:00:00 2001 From: David Metcalfe <80915+DavidMetcalfe@users.noreply.github.com> Date: Sat, 27 Jun 2026 17:39:52 -0700 Subject: [PATCH] fix(computer_use): mock _cua_no_overlay in existing tests, fix platform-dependent assertions - Add autouse fixture to TestMcpInvocationResolution to disable --no-overlay flag so existing tests assert baseline args - Make test_config_load_failure_fails_safe and test_missing_section_enables platform-aware (Linux auto-detect returns True, macOS/Windows False) --- tests/computer_use/test_cua_no_overlay.py | 8 +++++--- tests/tools/test_computer_use.py | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/computer_use/test_cua_no_overlay.py b/tests/computer_use/test_cua_no_overlay.py index 244fd39b6dc1..3b67a1b1f72b 100644 --- a/tests/computer_use/test_cua_no_overlay.py +++ b/tests/computer_use/test_cua_no_overlay.py @@ -47,15 +47,17 @@ class TestNoOverlayFlag: assert cua_backend._cua_no_overlay() is False def test_config_load_failure_fails_safe(self): - """Unreadable config => default to overlay enabled.""" + """Unreadable config => auto-detect (platform-dependent).""" with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")): - assert cua_backend._cua_no_overlay() is False + expected = sys.platform == "linux" + assert cua_backend._cua_no_overlay() is expected def test_missing_section_enables(self): with patch("hermes_cli.config.load_config", return_value={"other": {}}): - assert cua_backend._cua_no_overlay() is False + expected = sys.platform == "linux" + assert cua_backend._cua_no_overlay() is expected class TestMcpArgsOverlayFlag: diff --git a/tests/tools/test_computer_use.py b/tests/tools/test_computer_use.py index 44b5f1a5dbd1..502f24b61b5a 100644 --- a/tests/tools/test_computer_use.py +++ b/tests/tools/test_computer_use.py @@ -2795,6 +2795,13 @@ class TestMcpInvocationResolution: fields, wrong types) falls back to the literal `["mcp"]` baseline. """ + @pytest.fixture(autouse=True) + def _no_overlay_off(self): + """Disable the --no-overlay flag so tests assert baseline args.""" + with patch("tools.computer_use.cua_backend._cua_no_overlay", + return_value=False): + yield + @staticmethod def _fake_run(stdout: str = "", returncode: int = 0, raises: Exception = None): """Build a patched subprocess.run that yields the supplied result."""