diff --git a/tests/integration/test_dunamai.py b/tests/integration/test_dunamai.py index c68d602..932d030 100644 --- a/tests/integration/test_dunamai.py +++ b/tests/integration/test_dunamai.py @@ -1,6 +1,7 @@ import datetime as dt import os import shutil +import sys import time from contextlib import contextmanager from pathlib import Path @@ -39,6 +40,17 @@ def is_git_legacy() -> bool: return version < [2, 7] +def set_missing_env(key: str, value: str, alts: Optional[List[str]] = None) -> None: + if alts is None: + alts = [] + + for k in [key, *alts]: + if os.environ.get(k) is not None: + return + + os.environ[key] = value + + def make_run_callback(where: Path) -> Callable: def inner(command, expected_code: int = 0, env: Optional[dict] = None): _, out = _run_cmd(command, where=where, codes=[expected_code], env=env) @@ -796,6 +808,10 @@ def test__version__from_fossil(tmp_path) -> None: from_vcs = make_from_callback(Version.from_fossil) b = "trunk" + if sys.platform != "win32": + set_missing_env("FOSSIL_HOME", str(REPO / "tests"), ["HOME", "XDG_CONFIG_HOME"]) + set_missing_env("USER", "dunamai") + with chdir(vcs): run("fossil init repo") run("fossil open repo --force")