The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: stub the safe.directory pre-read by default; map privacydied's email
Tekniumfa425c942ead
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..0062eecd82b--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+privacydieddiff --git a/tests/conftest.py b/tests/conftest.pyindex acaca8d8c5f..62201be60ac 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -596,6 +596,23 @@ def _neutralize_kanban_memory_guard(request, monkeypatch):monkeypatch.setattr(_kbd_mod, "_system_memory_sample", lambda: {}, raising=False)[email protected](autouse=True)+def _neutralize_git_safe_directory_read(request, monkeypatch):+ """Skip the ``git config --get-all safe.directory`` pre-read in ``noninteractive_git_env()``.++ Many tests fake ``subprocess.run``/``Popen`` with a fixed sequence of expected git calls;+ the pre-read is an extra spawn that would trip them. Tests of the carve-out itself opt in+ with ``@pytest.mark.real_safe_directory``.+ """+ if request.node.get_closest_marker("real_safe_directory"):+ return+ try:+ from hermes_cli import _subprocess_compat+ except Exception:+ return+ monkeypatch.setattr(_subprocess_compat, "_user_safe_directories", lambda base_env: [], raising=False)++@pytest.fixture(autouse=True)def _neutralize_webbrowser(monkeypatch):"""Record browser-open attempts instead of opening real browser windows."""@@ -1160,6 +1177,11 @@ def pytest_configure(config): # noqa: D401 — pytest hook"child whose argv matches the gateway runtime matcher; only the ""real-gateway spawn check is lifted, os.kill stays guarded.",)+ config.addinivalue_line(+ "markers",+ "real_safe_directory: run the real `git config --get-all safe.directory` pre-read in "+ "noninteractive_git_env() (autouse fixture otherwise stubs it to no entries).",+ )config.addinivalue_line("markers",f"{_REQUIRES_WAL_MARK}: test needs the runtime to actually enable "diff --git a/tests/hermes_cli/test_noninteractive_git.py b/tests/hermes_cli/test_noninteractive_git.pyindex 0d36f099bd8..9280990c7c9 100644--- a/tests/hermes_cli/test_noninteractive_git.py+++ b/tests/hermes_cli/test_noninteractive_git.py@@ -97,6 +97,7 @@ class TestNoninteractiveGitEnv:assert values["sequence.editor"] == "true"assert values["diff.external"] == ""+ @pytest.mark.real_safe_directorydef test_safe_directory_preserves_git_ordering_and_reset_markers(self, tmp_path, monkeypatch):"""The user's effective trust policy is replayed verbatim, resets included.@@ -146,6 +147,7 @@ class TestNoninteractiveGitEnv:assert expected == ["*", "", "/trusted/only"], "git's documented reset shape changed"assert injected == expected+ @pytest.mark.real_safe_directorydef test_safe_directory_reset_still_revokes_wildcard_for_real_git(self, tmp_path):"""End-to-end: a revoked wildcard stays revoked, and the named repo stays usable.