Skip to content

Commit

Permalink
Add test coverage for Python version discovery with prereleases (#6823)
Browse files Browse the repository at this point in the history
Coverage for #6813 — reverting that
commit causes the 3.11.0b0 test case to fail.
  • Loading branch information
zanieb authored Aug 29, 2024
1 parent 9ea03ce commit a17c1e8
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions crates/uv-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,58 @@ mod tests {
Ok(())
}

#[test]
fn find_python_all_minors_prerelease() -> Result<()> {
let mut context = TestContext::new()?;
context.add_python_interpreters(&[
(true, ImplementationName::CPython, "python", "3.10.0"),
(true, ImplementationName::CPython, "python3", "3.10.0"),
(true, ImplementationName::CPython, "python3.11", "3.11.0b0"),
])?;

let python = context.run(|| {
find_python_installation(
&PythonRequest::parse(">= 3.11"),
EnvironmentPreference::Any,
PythonPreference::OnlySystem,
&context.cache,
)
})??;
assert_eq!(
python.interpreter().python_full_version().to_string(),
"3.11.0b0",
"We should find the 3.11 prerelease even though >=3.11 would normally exclude prereleases"
);

Ok(())
}

#[test]
fn find_python_all_minors_prerelease_next() -> Result<()> {
let mut context = TestContext::new()?;
context.add_python_interpreters(&[
(true, ImplementationName::CPython, "python", "3.10.0"),
(true, ImplementationName::CPython, "python3", "3.10.0"),
(true, ImplementationName::CPython, "python3.12", "3.12.0b0"),
])?;

let python = context.run(|| {
find_python_installation(
&PythonRequest::parse(">= 3.11"),
EnvironmentPreference::Any,
PythonPreference::OnlySystem,
&context.cache,
)
})??;
assert_eq!(
python.interpreter().python_full_version().to_string(),
"3.12.0b0",
"We should find the 3.12 prerelease"
);

Ok(())
}

#[test]
fn find_python_pypy_prefers_executable_with_implementation_name() -> Result<()> {
let mut context = TestContext::new()?;
Expand Down

0 comments on commit a17c1e8

Please sign in to comment.