From 1b1975781f372e4d7fe4f448eab86cea5441f2e7 Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Fri, 14 Aug 2026 16:56:26 +0530 Subject: [PATCH] test: use tmp_path fixture for import test HERMES_HOME The subprocess import test was creating .tmp-hermes-exec-ask-import/ in the repo root without cleanup. Switch to pytest's tmp_path fixture so the temp directory is auto-cleaned and never appears as untracked. --- tests/tools/test_cli_approval_exec_ask_leak.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/tools/test_cli_approval_exec_ask_leak.py b/tests/tools/test_cli_approval_exec_ask_leak.py index 1bb4da9974c40..e6137c398f09e 100644 --- a/tests/tools/test_cli_approval_exec_ask_leak.py +++ b/tests/tools/test_cli_approval_exec_ask_leak.py @@ -10,8 +10,10 @@ with no Approve/Deny UI. from __future__ import annotations import os +import shutil import subprocess import sys +import tempfile from pathlib import Path from unittest.mock import patch @@ -87,7 +89,7 @@ class TestCliApprovalSurvivesExecAskLeak: class TestGatewayRunImportDoesNotSetExecAsk: - def test_importing_gateway_run_does_not_set_exec_ask(self): + def test_importing_gateway_run_does_not_set_exec_ask(self, tmp_path): """Incidental imports must not poison CLI ask-mode process-wide.""" script = r""" import os, sys @@ -98,6 +100,7 @@ sys.path.insert(0, %r) import gateway.run # noqa: F401 print("EXEC_ASK=" + repr(os.environ.get("HERMES_EXEC_ASK"))) """ % (str(REPO_ROOT),) + hermes_home = tmp_path / "import-test-home" proc = subprocess.run( [sys.executable, "-c", script], cwd=str(REPO_ROOT), @@ -105,7 +108,7 @@ print("EXEC_ASK=" + repr(os.environ.get("HERMES_EXEC_ASK"))) text=True, env={ **os.environ, - "HERMES_HOME": str(REPO_ROOT / ".tmp-hermes-exec-ask-import"), + "HERMES_HOME": str(hermes_home), }, timeout=60, )