diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py index d8691fdf87c..dca10bb4462 100644 --- a/tests/agent/test_context_compressor.py +++ b/tests/agent/test_context_compressor.py @@ -65,11 +65,11 @@ class TestCompress: assert result == msgs def test_truncation_fallback_no_client(self, compressor): - # compressor has client=None and abort_on_summary_failure=False (default), - # so the LEGACY fallback path inserts a static "summary unavailable" - # placeholder and the middle window is dropped. + # Simulate "no summarizer available" explicitly. call_llm can otherwise + # discover the developer's real auxiliary credentials from auth state. msgs = [{"role": "system", "content": "System prompt"}] + self._make_messages(10) - result = compressor.compress(msgs) + with patch("agent.context_compressor.call_llm", side_effect=RuntimeError("no provider")): + result = compressor.compress(msgs) assert len(result) < len(msgs) # Should keep system message and last N assert result[0]["role"] == "system" diff --git a/tests/conftest.py b/tests/conftest.py index 3cdce42c495..0514702546b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -358,6 +358,10 @@ def _hermetic_environment(tmp_path, monkeypatch): monkeypatch.setenv("AWS_EC2_METADATA_DISABLED", "true") monkeypatch.setenv("AWS_METADATA_SERVICE_TIMEOUT", "1") monkeypatch.setenv("AWS_METADATA_SERVICE_NUM_ATTEMPTS", "1") + # Tirith auto-installs from GitHub when enabled and missing. Unit tests + # should never perform that implicit network/bootstrap path; Tirith-specific + # tests opt back in by patching the security config directly. + monkeypatch.setenv("TIRITH_ENABLED", "false") # 5. Reset plugin singleton so tests don't leak plugins from # ~/.hermes/plugins/ (which, per step 3, is now empty — but the diff --git a/tests/gateway/test_runner_startup_failures.py b/tests/gateway/test_runner_startup_failures.py index 438553f34ed..b82062e4090 100644 --- a/tests/gateway/test_runner_startup_failures.py +++ b/tests/gateway/test_runner_startup_failures.py @@ -207,6 +207,7 @@ async def test_start_gateway_replace_force_uses_terminate_pid(monkeypatch, tmp_p lambda **kwargs: 0, ) monkeypatch.setattr("gateway.status.terminate_pid", lambda pid, force=False: calls.append((pid, force))) + monkeypatch.setattr("gateway.status._pid_exists", lambda pid: True) monkeypatch.setattr("gateway.run.os.getpid", lambda: 100) monkeypatch.setattr("gateway.run.os.kill", lambda pid, sig: None) monkeypatch.setattr("time.sleep", lambda _: None) diff --git a/tests/tools/test_tirith_security.py b/tests/tools/test_tirith_security.py index b47c7a5ff58..6c771c6d482 100644 --- a/tests/tools/test_tirith_security.py +++ b/tests/tools/test_tirith_security.py @@ -831,7 +831,8 @@ class TestDiskFailureMarker: with patch("tools.tirith_security._failure_marker_path", return_value=marker): from tools.tirith_security import _mark_install_failed, _is_install_failed_on_disk _mark_install_failed("cosign_missing") - assert _is_install_failed_on_disk() # cosign still absent + with patch("tools.tirith_security.shutil.which", return_value=None): + assert _is_install_failed_on_disk() # cosign still absent # Now cosign appears on PATH with patch("tools.tirith_security.shutil.which", return_value="/usr/local/bin/cosign"): diff --git a/tests/tools/test_voice_mode.py b/tests/tools/test_voice_mode.py index 4c7ba74bd6e..3f7ada8c4a2 100644 --- a/tests/tools/test_voice_mode.py +++ b/tests/tools/test_voice_mode.py @@ -10,6 +10,18 @@ from unittest.mock import MagicMock, patch import pytest +def _non_wsl_proc_version(real_open): + """Return an open() shim that makes host WSL detection deterministic.""" + def _fake_open(file, *args, **kwargs): + if file == "/proc/version": + from io import StringIO + + return StringIO("Linux test-kernel") + return real_open(file, *args, **kwargs) + + return _fake_open + + # ============================================================================ # Fixtures # ============================================================================ @@ -68,6 +80,7 @@ class TestDetectAudioEnvironment: monkeypatch.delenv("SSH_CONNECTION", raising=False) monkeypatch.setattr("tools.voice_mode._import_audio", lambda: (MagicMock(), MagicMock())) + monkeypatch.setattr("builtins.open", _non_wsl_proc_version(open)) from tools.voice_mode import detect_audio_environment result = detect_audio_environment() @@ -225,6 +238,7 @@ class TestDetectAudioEnvironment: monkeypatch.setattr("tools.voice_mode.shutil.which", lambda cmd: "/data/data/com.termux/files/usr/bin/termux-microphone-record" if cmd == "termux-microphone-record" else None) monkeypatch.setattr("tools.voice_mode._termux_api_app_installed", lambda: True) monkeypatch.setattr("tools.voice_mode._import_audio", lambda: (_ for _ in ()).throw(ImportError("no audio libs"))) + monkeypatch.setattr("builtins.open", _non_wsl_proc_version(open)) from tools.voice_mode import detect_audio_environment result = detect_audio_environment()