The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: give four vacuous tests an assertion that can fail
kshitijk4poorb65972c1a58a
diff --git a/tests/hermes_cli/test_config.py b/tests/hermes_cli/test_config.pyindex 0ccc94d5090..b4e3ff1e872 100644--- a/tests/hermes_cli/test_config.py+++ b/tests/hermes_cli/test_config.py@@ -944,18 +944,13 @@ class TestConfigSupportFloor:with patch.dict(os.environ, {"HERMES_HOME": str(tmp_path)}):migrate_config(interactive=False, quiet=True)raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))- # Pin the golden version the fixtures were captured at, then compare- # the rest against the same-latest expectation. If _config_version has- # advanced past 33, only the version key may differ.+ # The fixtures were captured at _config_version 33; later migrations+ # may add keys, so the captured keys are a subset that must still hold.assert raw["_config_version"] == DEFAULT_CONFIG["_config_version"]- raw.pop("_config_version")exp = dict(expected)exp.pop("_config_version")- if DEFAULT_CONFIG["_config_version"] == 33:- assert raw == exp- else: # future migrations appended — golden subset must still hold- for key, val in exp.items():- assert raw.get(key) == val, f"parity drift on {key!r}"+ for key, val in exp.items():+ assert raw.get(key) == val, f"parity drift on {key!r}"assert (tmp_path / ".env").read_text(encoding="utf-8") == expected_envdiff --git a/tests/hermes_cli/test_profiles_s6_hooks.py b/tests/hermes_cli/test_profiles_s6_hooks.pyindex 56d9d40eb91..7b21bbb493f 100644--- a/tests/hermes_cli/test_profiles_s6_hooks.py+++ b/tests/hermes_cli/test_profiles_s6_hooks.py@@ -85,7 +85,9 @@ def _patch_detect_s6(monkeypatch: pytest.MonkeyPatch) -> None:)-def test_register_noop_on_host(monkeypatch: pytest.MonkeyPatch) -> None:+def test_register_noop_on_host(+ monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str],+) -> None:# NOTE: deliberately DO NOT patch detect_service_manager — we want# the real host detection to kick in and short-circuit before# get_service_manager is ever called. The lambda below is a@@ -95,8 +97,10 @@ def test_register_noop_on_host(monkeypatch: pytest.MonkeyPatch) -> None:"hermes_cli.service_manager.get_service_manager",lambda: _HostManager(),)- # Should NOT raise the AssertionError from _HostManager.register_maybe_register_gateway_service("hostprof")+ # The hook swallows errors into a printed warning, so reaching+ # _HostManager.register would surface here, not as a raise.+ assert capsys.readouterr().out == ""def test_register_passes_start_now_false(monkeypatch: pytest.MonkeyPatch) -> None:diff --git a/tests/plugins/test_retaindb_plugin.py b/tests/plugins/test_retaindb_plugin.pyindex e0b93c6d893..b066c507993 100644--- a/tests/plugins/test_retaindb_plugin.py+++ b/tests/plugins/test_retaindb_plugin.py@@ -268,7 +268,8 @@ class TestPrefetch:def test_queue_prefetch_skips_without_client(self):p = RetainDBMemoryProvider()- p.queue_prefetch("test") # Should not raise+ p.queue_prefetch("test")+ assert p._prefetch_threads == []def test_prefetch_returns_empty_when_nothing_cached(self, tmp_path, monkeypatch):p = self._make_initialized_provider(tmp_path, monkeypatch)diff --git a/tests/test_live_system_guard_self_test.py b/tests/test_live_system_guard_self_test.pyindex 468326d4cd4..3ba780323d8 100644--- a/tests/test_live_system_guard_self_test.py+++ b/tests/test_live_system_guard_self_test.py@@ -336,3 +336,5 @@ def test_bypass_marker_disables_guard():# so we get the real os.kill. Calling os.kill(os.getpid(), 0) just# checks that the PID exists — harmless.os.kill(os.getpid(), 0) # No exception — guard is OFF.+ # Signal 0 passes the guard too, so prove the patch itself is absent.+ assert isinstance(os.kill, types.BuiltinFunctionType)diff --git a/tests/tools/test_terminal_config_env_sync.py b/tests/tools/test_terminal_config_env_sync.pyindex 59b6cbc9852..50d0c02c020 100644--- a/tests/tools/test_terminal_config_env_sync.py+++ b/tests/tools/test_terminal_config_env_sync.py@@ -16,34 +16,12 @@ silently does nothing for that entry-point. This bug already shipped oncefor ``docker_run_as_host_user`` (gateway and CLI maps) and once for``docker_mount_cwd_to_workspace`` (gateway map).-This test guards against future drift by extracting all three maps via source-inspection and asserting they all bridge the same set of writable-``terminal.*`` keys. Source inspection (rather than importing the live-dicts) keeps the test independent of the user's ~/.hermes/config.yaml and-mirrors the pattern used in tests/hermes_cli/test_config_drift.py.+This test guards against future drift by driving each bridge with every+known ``terminal.*`` key and asserting they all write the same env var."""-import ast-import inspect---def _extract_dict_keys(source: str, dict_name: str) -> set[str]:- """Return the set of *key* strings in `dict_name = { "KEY": "v", ... }`."""- tree = ast.parse(source)- for node in ast.walk(tree):- if not isinstance(node, ast.Assign):- continue- targets = [t for t in node.targets if isinstance(t, ast.Name)]- if not any(t.id == dict_name for t in targets):- continue- if not isinstance(node.value, ast.Dict):- continue- out: set[str] = set()- for k in node.value.keys:- if isinstance(k, ast.Constant) and isinstance(k.value, str):- out.add(k.value)- return out- raise AssertionError(f"Could not find `{dict_name} = {{...}}` literal in source")+import os+from unittest.mock import patchdef _cli_env_map_keys() -> set[str]:@@ -52,13 +30,24 @@ def _cli_env_map_keys() -> set[str]:return set(cli._TERMINAL_ENV_MAPPINGS.keys())-def _gateway_env_map_keys() -> set[str]:- """terminal config keys bridged by gateway/run.py at module load."""- # gateway/run.py builds the dict at module top-level (not inside a- # function), so inspect the whole module source.- import gateway.run as gr- source = inspect.getsource(gr)- return _extract_dict_keys(source, "_terminal_env_map")+def _gateway_env_map() -> dict[str, str]:+ """terminal config key -> env var actually written by the gateway bridge."""+ import cli+ from gateway.run import _bridge_terminal_config_to_env+ from hermes_cli import config as hc_config++ probe = "/hermes-bridge-probe" # absolute, so the cwd placeholder skip never fires+ candidates = set(cli._TERMINAL_ENV_MAPPINGS) | set(hc_config.TERMINAL_CONFIG_ENV_MAP) | {"backend"}+ bridged: dict[str, str] = {}+ with patch.dict(os.environ): # restores the process env on exit+ for key in sorted(candidates):+ for var in [v for v in os.environ if v.startswith("TERMINAL_")]:+ del os.environ[var]+ _bridge_terminal_config_to_env({key: probe})+ written = [v for v, val in os.environ.items() if v.startswith("TERMINAL_") and val == probe]+ if written:+ (bridged[key],) = written+ return bridgeddef _save_config_env_sync_keys() -> set[str]:@@ -94,35 +83,34 @@ _CLI_ONLY_OK = frozenset({def test_cli_and_gateway_env_maps_agree():- """cli.py and gateway/run.py must bridge the same set of terminal keys.+ """cli.py and gateway/run.py must bridge each terminal key to the same env var.Both feed the same downstream consumer (terminal_tool). Drift betweenthem means a config.yaml setting that "works in CLI mode but not gatewaymode" (or vice-versa) — the bug class that shipped twice already."""- cli_keys = _cli_env_map_keys() - _CLI_ONLY_OK- gw_keys = _gateway_env_map_keys()+ import cli- # Normalize the legacy `env_type` alias: cli.py accepts both `env_type`- # and `backend` as source keys for TERMINAL_ENV; gateway only accepts- # `backend`. Since cli.py copies `backend` → `env_type` before the- # lookup, they're equivalent. Remove `backend` from the gateway side- # to avoid a spurious "backend missing from cli" failure.- gw_keys = gw_keys - {"backend"}+ cli_map = {k: v for k, v in cli._TERMINAL_ENV_MAPPINGS.items() if k not in _CLI_ONLY_OK}+ gw_map = _gateway_env_map()+ # cli.py copies the canonical `backend` key onto the legacy `env_type`+ # alias before bridging, so the gateway's `backend` is cli's `env_type`.+ gw_map.pop("backend", None)- missing_in_gateway = cli_keys - gw_keys- missing_in_cli = gw_keys - cli_keys+ missing_in_gateway = sorted(set(cli_map) - set(gw_map))+ missing_in_cli = sorted(set(gw_map) - set(cli_map))+ mismatched = {k: (cli_map[k], gw_map[k]) for k in set(cli_map) & set(gw_map) if cli_map[k] != gw_map[k]}assert not missing_in_gateway, (- f"Keys in cli.py env_mappings but missing from gateway/run.py "- f"_terminal_env_map: {sorted(missing_in_gateway)}. Add them to "- f"both maps (same bug class as docker_run_as_host_user shipping "- f"wired in cli but not gateway in April 2026)."+ f"Keys the CLI bridges but gateway/run.py _bridge_terminal_config_to_env "+ f"ignores: {missing_in_gateway}. Add them to both maps (same bug class "+ f"as docker_run_as_host_user shipping wired in cli but not gateway).")assert not missing_in_cli, (- f"Keys in gateway/run.py _terminal_env_map but missing from cli.py "- f"env_mappings: {sorted(missing_in_cli)}. Add them to both maps."+ f"Keys the gateway bridges but cli.py env_mappings ignores: "+ f"{missing_in_cli}. Add them to both maps.")+ assert not mismatched, f"Same key bridged to different env vars (cli, gateway): {mismatched}"def test_save_config_set_bridges_every_cli_terminal_key():