Add test case for Python pre-release versions from VIRTUAL_ENV (#7437)

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

View file

@ -964,7 +964,7 @@ mod tests {
#[test]
fn find_python_from_active_python() -> Result<()> {
let context = TestContext::new()?;
let venv = context.tempdir.child(".venv");
let venv = context.tempdir.child("some-venv");
TestContext::mock_venv(&venv, "3.12.0")?;
let python =
@ -985,6 +985,31 @@ mod tests {
Ok(())
}
#[test]
fn find_python_from_active_python_prerelease() -> Result<()> {
let mut context = TestContext::new()?;
context.add_python_versions(&["3.12.0"])?;
let venv = context.tempdir.child("some-venv");
TestContext::mock_venv(&venv, "3.13.0rc1")?;
let python =
context.run_with_vars(&[("VIRTUAL_ENV", Some(venv.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.0rc1",
"We should prefer the active environment"
);
Ok(())
}
#[test]
fn find_python_from_conda_prefix() -> Result<()> {
let context = TestContext::new()?;