Make the setup tests pass on Windows

The tests assumed a POSIX host, but pytest also runs on windows-latest.
Both path flavours are now built with PurePosixPath and PureWindowsPath,
which work on either host, the bin/Scripts layout is asserted against the
host, and the executable bit is only checked where it exists.

Also drops the trailing separator from PATH when PATH is unset, since an
empty entry makes Unix search the working directory for executables.
This commit is contained in:
Jesse Hills
2026-09-01 08:58:51 +12:00
parent f8ea4873b6
commit 7b2e2850f2
2 changed files with 46 additions and 28 deletions
+6 -1
View File
@@ -88,7 +88,12 @@ def venv_environment(venv: Path) -> dict[str, str]:
env = dict(os.environ)
env["VIRTUAL_ENV"] = str(venv)
env.pop("PYTHONHOME", None)
env["PATH"] = os.pathsep.join([str(bin_dir(venv)), env.get("PATH", "")])
path = str(bin_dir(venv))
# An empty entry would be appended if PATH is unset, and on Unix that means
# the working directory is searched for executables.
if existing := env.get("PATH"):
path = os.pathsep.join([path, existing])
env["PATH"] = path
return env