From 7acd7d2eda18c815ae8ea72de8e91aa6ec97ae67 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 24 Jun 2026 09:26:34 +0200 Subject: [PATCH 1/2] test: isolate integration test home Assisted-by: Codex (model: GPT-5, autonomous) --- tests/integrations/conftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/integrations/conftest.py b/tests/integrations/conftest.py index 54f59e23a7..42135402a9 100644 --- a/tests/integrations/conftest.py +++ b/tests/integrations/conftest.py @@ -1,8 +1,24 @@ """Shared test helpers for integration tests.""" +import pytest + from specify_cli.integrations.base import MarkdownIntegration +@pytest.fixture(autouse=True) +def _isolate_integration_home(monkeypatch: pytest.MonkeyPatch, tmp_path): + """Keep integration tests from reading or writing the real user home.""" + home = tmp_path / "home" + for path in (home, home / ".cache", home / ".config", home / ".local" / "share"): + path.mkdir(parents=True, exist_ok=True) + + monkeypatch.setenv("HOME", str(home)) + monkeypatch.setenv("USERPROFILE", str(home)) + monkeypatch.setenv("XDG_CACHE_HOME", str(home / ".cache")) + monkeypatch.setenv("XDG_CONFIG_HOME", str(home / ".config")) + monkeypatch.setenv("XDG_DATA_HOME", str(home / ".local" / "share")) + + class StubIntegration(MarkdownIntegration): """Minimal concrete integration for testing.""" From e1aaf479d12e6af0b5c2b7bd076cd5600f0543a8 Mon Sep 17 00:00:00 2001 From: Pascal Date: Fri, 3 Jul 2026 00:03:05 +0200 Subject: [PATCH 2/2] test: assert integration home isolation Assisted-by: Codex (model: GPT-5, autonomous) --- tests/integrations/test_home_isolation.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/integrations/test_home_isolation.py diff --git a/tests/integrations/test_home_isolation.py b/tests/integrations/test_home_isolation.py new file mode 100644 index 0000000000..e79ff5dff6 --- /dev/null +++ b/tests/integrations/test_home_isolation.py @@ -0,0 +1,21 @@ +"""Regression tests for integration-test environment isolation.""" + +from __future__ import annotations + +import os +from pathlib import Path + + +def test_integration_tests_use_tmp_home(tmp_path: Path) -> None: + home = tmp_path / "home" + + assert Path(os.environ["HOME"]) == home + assert Path(os.environ["USERPROFILE"]) == home + assert Path(os.environ["XDG_CACHE_HOME"]) == home / ".cache" + assert Path(os.environ["XDG_CONFIG_HOME"]) == home / ".config" + assert Path(os.environ["XDG_DATA_HOME"]) == home / ".local" / "share" + + assert home.is_dir() + assert (home / ".cache").is_dir() + assert (home / ".config").is_dir() + assert (home / ".local" / "share").is_dir()