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.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 21:03:24 +02:00
1 parent e7a64d6a08
commit 0ecd830028
2 files changed
+7 -1

No files matched your search

+3
View File
@@ -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:
+4 -1
View File
@@ -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",