From 0ecd83002858a40e5a80b68bf311f57ebe993ffd Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 23 Oct 2026 21:03:24 +0200 Subject: [PATCH] fix: keep install tests off the host environment On a WSL host install.main() reads USERPROFILE, APPDATA and the rest through cmd.exe and sets them in os.environ. Two selection tests left them set, and the detection test, run later in the jsonschema-free suite, found a Scoop folder no registry rule publishes. The selection tests restore os.environ, and the detection test clears the Windows variables it does not set. --- tests/test_install.py | 3 +++ tests/test_install_selection.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_install.py b/tests/test_install.py index 4da52996..c4dbb4ba 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -1045,6 +1045,9 @@ class DetectionFollowsTheRegistry(unittest.TestCase): env = { "HOME": str(root / "home"), "APPDATA": str(root / "appdata"), "ProgramFiles": str(root / "pf"), "ProgramFiles(x86)": str(root / "pf86"), + # Not the host's: a WSL session can hold them. + "USERPROFILE": "", "LOCALAPPDATA": "", "ProgramData": "", + "SCOOP": "", "SCOOP_GLOBAL": "", } def expand(text: str) -> str: diff --git a/tests/test_install_selection.py b/tests/test_install_selection.py index 97b969b3..07ac982f 100644 --- a/tests/test_install_selection.py +++ b/tests/test_install_selection.py @@ -362,7 +362,10 @@ class DecliningTheSizePointsAtTheChoice(unittest.TestCase): def _run(self, answers: list[str], *options: str) -> str: replies = iter(answers) out = io.StringIO() - with FakeRepository() as repo, \ + # main() on a WSL host reads the Windows variables through cmd.exe + # and sets them in os.environ: restored here, they leaked into every + # later test (USERPROFILE added a Scoop folder to detection). + with FakeRepository() as repo, mock.patch.dict(os.environ), \ mock.patch.object(sys, "argv", ["install.py", "--platform", "retroarch", "--dest", str(repo.dest), *options]), \ mock.patch.object(install, "MANIFEST_URL",