rm InsertPathEntry; use os.PathListSeparator

This commit is contained in:
Denis Bilenko 2024-12-19 10:14:06 +01:00
parent dcfeeacea2
commit 5b4c7624fe
2 changed files with 2 additions and 23 deletions

View File

@ -61,25 +61,3 @@ func Chdir(t TestingT, dir string) string {
return wd
}
func InsertPathEntry(t TestingT, path string) {
var separator string
if runtime.GOOS == "windows" {
separator = ";"
} else {
separator = ":"
}
t.Setenv("PATH", path+separator+os.Getenv("PATH"))
}
func InsertVirtualenvInPath(t TestingT, venvPath string) {
if runtime.GOOS == "windows" {
// https://github.com/pypa/virtualenv/commit/993ba1316a83b760370f5a3872b3f5ef4dd904c1
venvPath = filepath.Join(venvPath, "Scripts")
} else {
venvPath = filepath.Join(venvPath, "bin")
}
InsertPathEntry(t, venvPath)
}

View File

@ -106,7 +106,8 @@ func RequireActivatedPythonEnv(t *testing.T, ctx context.Context, opts *VenvOpts
require.NoError(t, err)
require.DirExists(t, opts.BinPath)
testutil.InsertPathEntry(t, opts.BinPath)
newPath := fmt.Sprintf("%s%c%s", opts.BinPath, os.PathListSeparator, os.Getenv("PATH"))
t.Setenv("PATH", newPath)
pythonExe, err := python.DetectExecutable(ctx)
require.NoError(t, err)