Skip to content

Commit 6220532

Browse files
authoredAug 26, 2024··
Test for .venv symlink (#6597)
For various reasons, I have a preference for out of tree virtual environments. Things just work if I symlink, but I don't know that this is guaranteed, so I thought I'd add a test for it. It looks like there's another code path that matters (`FoundInterpreter::discover -> PythonEnvironment::from_root`) for the higher level commands, but couldn't spot a good place to test that. Related discussion: #1495 (comment) / #1578 (comment)
1 parent 50997bc commit 6220532

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎crates/uv-python/src/lib.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,32 @@ mod tests {
15621562
Ok(())
15631563
}
15641564

1565+
#[test]
1566+
fn find_python_venv_symlink() -> Result<()> {
1567+
let context = TestContext::new()?;
1568+
1569+
let venv = context.tempdir.child("target").child("env");
1570+
TestContext::mock_venv(&venv, "3.10.6")?;
1571+
let symlink = context.tempdir.child("proj").child(".venv");
1572+
context.tempdir.child("proj").create_dir_all()?;
1573+
symlink.symlink_to_dir(venv)?;
1574+
1575+
let python = context.run(|| {
1576+
find_python_installation(
1577+
&PythonRequest::parse("../proj/.venv"),
1578+
EnvironmentPreference::Any,
1579+
PythonPreference::OnlySystem,
1580+
&context.cache,
1581+
)
1582+
})??;
1583+
assert_eq!(
1584+
python.interpreter().python_full_version().to_string(),
1585+
"3.10.6",
1586+
"We should find the symlinked venv"
1587+
);
1588+
Ok(())
1589+
}
1590+
15651591
#[test]
15661592
fn find_python_treats_missing_file_path_as_file() -> Result<()> {
15671593
let context = TestContext::new()?;

0 commit comments

Comments
 (0)
Please sign in to comment.