From 91ceebf5d51abbc56d5a12f194010ecfad6551aa Mon Sep 17 00:00:00 2001 From: Shantanu Jain Date: Sun, 25 Aug 2024 01:02:45 -0700 Subject: [PATCH] Test for .venv symlink --- crates/uv-python/src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index 9f8652b2c06f..d51fedeb5da8 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -1562,6 +1562,32 @@ mod tests { Ok(()) } + #[test] + fn find_python_venv_symlink() -> Result<()> { + let context = TestContext::new()?; + + let venv = context.tempdir.child("target").child("env"); + TestContext::mock_venv(&venv, "3.10.6")?; + let symlink = context.tempdir.child("proj").child(".venv"); + context.tempdir.child("proj").create_dir_all()?; + symlink.symlink_to_dir(venv)?; + + let python = context.run(|| { + find_python_installation( + &PythonRequest::parse("../proj/.venv"), + EnvironmentPreference::Any, + PythonPreference::OnlySystem, + &context.cache, + ) + })??; + assert_eq!( + python.interpreter().python_full_version().to_string(), + "3.10.6", + "We should find the symlinked venv" + ); + Ok(()) + } + #[test] fn find_python_treats_missing_file_path_as_file() -> Result<()> { let context = TestContext::new()?;