Add test coverage for Python version discovery with prereleases (#6823)

Coverage for https://github.com/astral-sh/uv/pull/6813 — reverting that
commit causes the 3.11.0b0 test case to fail.
This commit is contained in:
Zanie Blue 2024-08-29 13:29:22 -05:00 committed by GitHub
parent 9ea03ceb38
commit a17c1e8e40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()?;