Skip to content

Commit 0d8c106

Browse files
groksrcclaude
andcommitted
fix(test): set USERPROFILE in test-int config_home fixture on Windows
Hundreds of ``test-int/`` tests were failing on Windows CI with ``Project not found: 'main'`` after resolve_data_dir() was simplified to use ``Path.home()`` directly (#743). Root cause: ``Path.home()`` reads ``$HOME`` on POSIX and ``%USERPROFILE%`` on Windows. The ``test-int/conftest.py`` ``config_home`` fixture only monkeypatched ``HOME``, which worked before because ``ConfigManager.data_dir_path`` used ``os.getenv("HOME", Path.home())`` — that preferred ``HOME`` even on Windows. Now that ``Path.home()`` is called directly, ``USERPROFILE`` wins and the fixture redirects nothing, so the test data dir falls back to the real user home where no ``main`` project is configured. Mirror the pattern already used in ``tests/conftest.py:config_home``: when running on Windows, also set ``USERPROFILE`` to ``tmp_path`` so ``Path.home()`` sees the redirected location. No-op on POSIX. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
1 parent fe92c06 commit 0d8c106

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test-int/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,13 @@ async def test_project(config_home, engine_factory) -> Project:
307307

308308
@pytest.fixture
309309
def config_home(tmp_path, monkeypatch) -> Path:
310+
# Patch both HOME and USERPROFILE so Path.home() returns the test dir on
311+
# every platform — Path.home() reads HOME on POSIX and USERPROFILE on
312+
# Windows, and ConfigManager.data_dir_path now goes through Path.home()
313+
# via resolve_data_dir(). Must mirror tests/conftest.py:config_home.
310314
monkeypatch.setenv("HOME", str(tmp_path))
315+
if os.name == "nt":
316+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
311317
# Set BASIC_MEMORY_HOME to the test directory
312318
monkeypatch.setenv("BASIC_MEMORY_HOME", str(tmp_path / "basic-memory"))
313319
return tmp_path

0 commit comments

Comments
 (0)