From 7ba5d75f3a92404c4b1f729508b0c026f61db062 Mon Sep 17 00:00:00 2001 From: qbot Date: Thu, 22 Oct 2026 10:25:51 +0000 Subject: [PATCH] test: isolate $HOME per test so media fallback stops writing ~/agenthub-media test_channels_e2e / test_relay_no_stack / test_session_manager drive prompt() with agents that lack cwd_whitelist, so the ~/agenthub-media fallback created directories in the real home directory on every run. --- tests/conftest.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..a93bb96 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +"""Shared test isolation. + +Several tests drive ``SessionManager.prompt(files=...)`` / ``_media_dir()`` with +agents that have no ``cwd_whitelist``, which makes the fallback path write to +``~/agenthub-media``. Pointing ``HOME`` at a per-test temp dir keeps the suite +from littering the real home directory. +""" +from __future__ import annotations + +import pytest + + +@pytest.fixture(autouse=True) +def isolated_home(tmp_path, monkeypatch): + """Per-test ``$HOME`` so nothing is written to the real home directory.""" + home = tmp_path / "home" + home.mkdir() + monkeypatch.setenv("HOME", str(home)) + return home