always resolve symlinks for TemporaryDirectory

On macOS mktemp returns a temporary directory in a symlink.
Nix has a bug where it won't accept path:// located in a symlink.
This avoid this issue by always resolving symlinks as returned by
TemporaryDirectory.
This commit is contained in:
Jörg Thalheim
2025-03-19 16:31:36 +01:00
parent 7fef29d7aa
commit 93cbe62765
12 changed files with 55 additions and 55 deletions

View File

@@ -19,9 +19,10 @@ def temporary_home(monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
monkeypatch.chdir(str(path))
yield path
else:
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
with tempfile.TemporaryDirectory(prefix="pytest-") as _dirpath:
dirpath = Path(_dirpath)
monkeypatch.setenv("HOME", str(dirpath))
monkeypatch.setenv("XDG_CONFIG_HOME", str(Path(dirpath) / ".config"))
monkeypatch.setenv("XDG_CONFIG_HOME", str(dirpath / ".config"))
monkeypatch.chdir(str(dirpath))
log.debug("Temp HOME directory: %s", str(dirpath))
yield Path(dirpath)
yield dirpath