Skip to content

Commit

Permalink
Fix lock_requires_python test case
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/uv/tests/common/mod.rs
  • Loading branch information
zanieb committed Jun 10, 2024
1 parent 379517d commit 662a4c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion crates/uv-toolchain/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ mod tests {
ToolchainRequest::Version(VersionRequest::from_str(">=3.12").unwrap())
);
assert_eq!(
ToolchainRequest::parse(">=3.12"),
ToolchainRequest::parse(">=3.12,<3.13"),
ToolchainRequest::Version(VersionRequest::from_str(">=3.12,<3.13").unwrap())
);
assert_eq!(
Expand Down
6 changes: 5 additions & 1 deletion crates/uv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,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")
.env("UV_TEST_PYTHON_PATH", "/dev/null")
.current_dir(&self.temp_dir);
Expand All @@ -250,7 +251,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 662a4c2

Please sign in to comment.