mirror of https://github.com/astral-sh/uv
Add `find_uv_bin` test cases by Python version (#15181)
Regression coverage for https://github.com/astral-sh/uv/issues/15176
This commit is contained in:
parent
1567cc862f
commit
6b5d309d28
|
|
@ -382,3 +382,295 @@ fn find_uv_bin_user_bin() {
|
|||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py38() {
|
||||
let context = TestContext::new("3.8")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r#"
|
||||
success: false
|
||||
exit_code: 1
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Traceback (most recent call last):
|
||||
File "<string>", line 1, in <module>
|
||||
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
|
||||
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
|
||||
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
|
||||
for part, match_part in zip(
|
||||
TypeError: zip() takes no keyword arguments
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py39() {
|
||||
let context = TestContext::new("3.9")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r#"
|
||||
success: false
|
||||
exit_code: 1
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Traceback (most recent call last):
|
||||
File "<string>", line 1, in <module>
|
||||
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
|
||||
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
|
||||
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
|
||||
for part, match_part in zip(
|
||||
TypeError: zip() takes no keyword arguments
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py310() {
|
||||
let context = TestContext::new("3.10")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[VENV]/[BIN]/uv
|
||||
|
||||
----- stderr -----
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py311() {
|
||||
let context = TestContext::new("3.11")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[VENV]/[BIN]/uv
|
||||
|
||||
----- stderr -----
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py312() {
|
||||
let context = TestContext::new("3.12")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[VENV]/[BIN]/uv
|
||||
|
||||
----- stderr -----
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py313() {
|
||||
let context = TestContext::new("3.13")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[VENV]/[BIN]/uv
|
||||
|
||||
----- stderr -----
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_uv_bin_py314() {
|
||||
let context = TestContext::new("3.14")
|
||||
.with_filtered_python_names()
|
||||
.with_filtered_virtualenv_bin()
|
||||
.with_filtered_exe_suffix()
|
||||
.with_filter(user_scheme_bin_filter())
|
||||
// Target installs always use "bin" on all platforms. On Windows,
|
||||
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
|
||||
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
|
||||
|
||||
// Install in a virtual environment
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ uv==0.1.0 (from file://[WORKSPACE]/scripts/packages/fake-uv)
|
||||
"
|
||||
);
|
||||
|
||||
// We should find the binary in the virtual environment
|
||||
uv_snapshot!(context.filters(), context.python_command()
|
||||
.arg("-c")
|
||||
.arg("import uv; print(uv.find_uv_bin())"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
[VENV]/[BIN]/uv
|
||||
|
||||
----- stderr -----
|
||||
"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue