Skip to content

Commit

Permalink
Do not automatically activate the virtual environment in `uv python f…
Browse files Browse the repository at this point in the history
…ind` tests
  • Loading branch information
zanieb committed Jan 17, 2025
1 parent 5434cc0 commit f5d0149
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/uv/tests/it/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ impl TestContext {
.env(EnvVars::UV_PREVIEW, "1")
.env(EnvVars::UV_PYTHON_INSTALL_DIR, "")
.current_dir(&self.temp_dir);
self.add_shared_args(&mut command, true);
self.add_shared_args(&mut command, false);
command
}

Expand Down
20 changes: 8 additions & 12 deletions crates/uv/tests/it/python_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ fn python_find() {
----- stdout -----
----- stderr -----
error: Failed to inspect Python interpreter from active virtual environment at `.venv/bin/python3`
Caused by: Python interpreter not found at `[VENV]/bin/python3`
error: No interpreter found in virtual environments, managed installations, or search path
"###);
}

Expand Down Expand Up @@ -125,8 +124,7 @@ fn python_find() {
----- stdout -----
----- stderr -----
error: Failed to inspect Python interpreter from active virtual environment at `.venv/bin/python3`
Caused by: Python interpreter not found at `[VENV]/bin/python3`
error: No interpreter found for PyPy in virtual environments, managed installations, or search path
"###);
}

Expand Down Expand Up @@ -538,8 +536,7 @@ fn python_find_unsupported_version() {
----- stdout -----
----- stderr -----
error: Failed to inspect Python interpreter from active virtual environment at `.venv/bin/python3`
Caused by: Python interpreter not found at `[VENV]/bin/python3`
error: No interpreter found for Python 4.2 in virtual environments, managed installations, or search path
"###);

// Request a low version with a range
Expand All @@ -549,8 +546,7 @@ fn python_find_unsupported_version() {
----- stdout -----
----- stderr -----
error: Failed to inspect Python interpreter from active virtual environment at `.venv/bin/python3`
Caused by: Python interpreter not found at `[VENV]/bin/python3`
error: No interpreter found for Python <3.0 in virtual environments, managed installations, or search path
"###);

// Request free-threaded Python on unsupported version
Expand All @@ -573,7 +569,7 @@ fn python_find_venv_invalid() {
.with_filtered_virtualenv_bin();

// We find the virtual environment
uv_snapshot!(context.filters(), context.python_find(), @r###"
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::VIRTUAL_ENV, context.venv.as_os_str()), @r###"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -585,7 +581,7 @@ fn python_find_venv_invalid() {
// If the binaries are missing from a virtual environment, we fail
fs_err::remove_dir_all(venv_bin_path(&context.venv)).unwrap();

uv_snapshot!(context.filters(), context.python_find(), @r###"
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::VIRTUAL_ENV, context.venv.as_os_str()), @r###"
success: false
exit_code: 2
----- stdout -----
Expand All @@ -596,7 +592,7 @@ fn python_find_venv_invalid() {
"###);

// Unless the virtual environment is not active
uv_snapshot!(context.filters(), context.python_find().env_remove(EnvVars::VIRTUAL_ENV), @r###"
uv_snapshot!(context.filters(), context.python_find(), @r###"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -608,7 +604,7 @@ fn python_find_venv_invalid() {
// If there's not a `pyvenv.cfg` file, it's also non-fatal, we ignore the environment
fs_err::remove_file(context.venv.join("pyvenv.cfg")).unwrap();

uv_snapshot!(context.filters(), context.python_find(), @r###"
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::VIRTUAL_ENV, context.venv.as_os_str()), @r###"
success: true
exit_code: 0
----- stdout -----
Expand Down

0 comments on commit f5d0149

Please sign in to comment.