mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
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: https://github.com/astral-sh/uv/issues/1495#issuecomment-1950442191 / https://github.com/astral-sh/uv/issues/1578#issuecomment-1949911871
This commit is contained in:
parent
50997bcb41
commit
6220532373
1 changed files with 26 additions and 0 deletions
|
@ -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()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue