fix handling of Dir option; use TempDir in test

This commit is contained in:
Denis Bilenko 2024-12-19 15:25:45 +01:00
parent 56785cf555
commit 1357f4a78b
2 changed files with 5 additions and 4 deletions

View File

@ -42,9 +42,6 @@ func CreatePythonEnv(opts *VenvOpts) error {
if opts.Name == "" {
opts.Name = testutil.RandomName("test-venv-")
}
if opts.Dir != "" {
opts.Dir = "."
}
cmd := exec.Command("uv", "venv", opts.Name, "--python", opts.PythonVersion, "--seed", "-q")
cmd.Stdout = os.Stdout

View File

@ -15,7 +15,11 @@ func TestVenvSuccess(t *testing.T) {
for _, pythonVersion := range []string{"3.11", "3.12"} {
t.Run(pythonVersion, func(t *testing.T) {
ctx := context.Background()
opts := VenvOpts{PythonVersion: pythonVersion}
dir := t.TempDir()
opts := VenvOpts{
PythonVersion: pythonVersion,
Dir: dir,
}
RequireActivatedPythonEnv(t, ctx, &opts)
require.DirExists(t, opts.EnvPath)
require.DirExists(t, opts.BinPath)