also override XDG_DATA_HOME in tests

otherwise tests will fail if XDG_DATA_HOME is set by a user
This commit is contained in:
Jörg Thalheim
2023-11-09 16:39:16 +01:00
parent af0714132d
commit b8ed607658

View File

@@ -21,6 +21,7 @@ def temporary_home(monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]:
else:
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
monkeypatch.setenv("HOME", str(dirpath))
monkeypatch.setenv("XDG_DATA_HOME", str(Path(dirpath) / ".local/share"))
monkeypatch.chdir(str(dirpath))
log.debug("Temp HOME directory: %s", str(dirpath))
yield Path(dirpath)