Add test case for Python pre-release versions from parent interpreter (#7438)

This commit is contained in:
Zanie Blue 2024-09-16 15:41:58 -05:00 committed by GitHub
parent e8899fe7f9
commit 6066989ed4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1254,6 +1254,39 @@ mod tests {
Ok(())
}
#[test]
fn find_python_from_parent_interpreter_prerelease() -> Result<()> {
let mut context = TestContext::new()?;
context.add_python_versions(&["3.12.0"])?;
let parent = context.tempdir.child("python").to_path_buf();
TestContext::create_mock_interpreter(
&parent,
&PythonVersion::from_str("3.13.0rc2").unwrap(),
ImplementationName::CPython,
// Note we mark this as a system interpreter instead of a virtual environment
true,
)?;
let python = context.run_with_vars(
&[("UV_INTERNAL__PARENT_INTERPRETER", Some(parent.as_os_str()))],
|| {
find_python_installation(
&PythonRequest::Any,
EnvironmentPreference::Any,
PythonPreference::OnlySystem,
&context.cache,
)
},
)??;
assert_eq!(
python.interpreter().python_full_version().to_string(),
"3.13.0rc2",
"We should find the parent interpreter"
);
Ok(())
}
#[test]
fn find_python_active_python_skipped_if_system_required() -> Result<()> {
let mut context = TestContext::new()?;