"""Filesystem layout. RUNTIME_DIR and DATA_DIR are read once, at import time (see paths.py's module docstring), so pinning a property of how they're derived means reloading the module under a patched environment rather than reading the live attributes. """ from __future__ import annotations import importlib from code_index import paths def test_runtime_dir_does_not_follow_data_dir(monkeypatch): """The embedding server's pid file belongs to the server, not to whichever worktree's index CODE_INDEX_DATA happens to point at.""" monkeypatch.setenv("CODE_INDEX_DATA", "/tmp/some-worktree/.index") monkeypatch.delenv("CODE_INDEX_RUNTIME", raising=False) importlib.reload(paths) try: assert paths.DATA_DIR == "/tmp/some-worktree/.index" assert "some-worktree" not in paths.RUNTIME_DIR finally: monkeypatch.undo() importlib.reload(paths)