Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,22 @@ def bind_inline_executor(
spawner.bind(app.workflows.queue.executor)


@pytest.fixture
@pytest.fixture(autouse=True)
def isolated_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
home = tmp_path / "home"
home.mkdir()
# `home_dir()` resolves `~` through `Path.home()`. POSIX reads $HOME, but
# Windows reads %USERPROFILE% and ignores $HOME entirely, so patching only
# $HOME leaves user state pointing at the real `~/.codealmanac`.
monkeypatch.setenv("HOME", str(home))
monkeypatch.setenv("USERPROFILE", str(home))
resolved = Path.home()
if resolved != home:
raise RuntimeError(
"isolated_home failed to redirect the user home: "
f"Path.home() is {resolved}, expected {home}. "
"Tests must never read or write the real ~/.codealmanac."
)
yield home


Expand Down