Skip to content

Commit

Permalink
Fix lock_requires_python test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jun 10, 2024
1 parent ea9c519 commit 1a449ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
10 changes: 6 additions & 4 deletions crates/uv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use uv_configuration::PreviewMode;
use uv_cache::Cache;
use uv_fs::Simplified;
use uv_toolchain::managed::InstalledToolchains;
use uv_toolchain::{
virtualenv_python_executable, PythonVersion, Toolchain,
};
use uv_toolchain::{virtualenv_python_executable, PythonVersion, Toolchain};

// Exclude any packages uploaded after this date.
pub static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
Expand Down Expand Up @@ -238,6 +236,7 @@ impl TestContext {
.arg("--cache-dir")
.arg(self.cache_dir.path())
.env("VIRTUAL_ENV", self.venv.as_os_str())
.env("UV_TEST_PYTHON_PATH", "/dev/null")
.env("UV_NO_WRAP", "1")
.current_dir(&self.temp_dir);

Expand All @@ -253,7 +252,10 @@ impl TestContext {
/// Create a `uv lock` command with options shared across scenarios.
pub fn lock(&self) -> std::process::Command {
let mut command = self.lock_without_exclude_newer();
command.arg("--exclude-newer").arg(EXCLUDE_NEWER);
command
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("UV_TEST_PYTHON_PATH", "/dev/null");
command
}

Expand Down
28 changes: 13 additions & 15 deletions crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,29 +2065,27 @@ fn lock_requires_python() -> Result<()> {
});

// Validate that attempting to install with an unsupported Python version raises an error.
let context = TestContext::new("3.8");
let context38 = TestContext::new("3.8");

fs_err::copy(pyproject_toml, context.temp_dir.join("pyproject.toml"))?;
fs_err::copy(&lockfile, context.temp_dir.join("uv.lock"))?;
fs_err::copy(pyproject_toml, context38.temp_dir.join("pyproject.toml"))?;
fs_err::copy(&lockfile, context38.temp_dir.join("uv.lock"))?;

let filters: Vec<_> = context38
.filters()
.into_iter()
.chain(context.filters())
.collect();

// Install from the lockfile.
uv_snapshot!(context.filters(), context.sync(), @r###"
success: true
exit_code: 0
uv_snapshot!(filters, context38.sync(), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
warning: `uv sync` is experimental and may change without warning.
Removing virtual environment at: [VENV]/
Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: [VENV]/
Downloaded 5 packages in [TIME]
Installed 5 packages in [TIME]
+ attrs==23.2.0
+ cattrs==23.2.3
+ lsprotocol==2023.0.1
+ project==0.1.0 (from file://private/var/folders/6p/k5sd5z7j31b31pq4lhn0l8d80000gn/T/.tmp2LoTc2)
+ pygls==1.3.0
error: No interpreter found for Python >=3.12 in provided path, active virtual environment, or search path
"###);

Ok(())
Expand Down

0 comments on commit 1a449ca

Please sign in to comment.