From 6de8c295e3a66f8b7b2e78c4ecfd54fd4946349f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 16 Sep 2024 14:54:47 -0500 Subject: [PATCH] Add test case for Python pre-release versions from parent interpreter --- crates/uv-python/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index 82fe49bd83ec..a9470a985ba2 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -1229,6 +1229,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()?;