Move python bin filtering into test that needs it (#15305)

Closes #15188
This commit is contained in:
Zanie Blue
2025-08-15 08:06:52 -05:00
committed by GitHub
parent d75ab0c316
commit 77fe8d2e60
2 changed files with 25 additions and 25 deletions
-23
View File
@@ -600,29 +600,6 @@ impl TestContext {
.map(|pattern| (pattern.to_string(), format!("[PYTHON-{version}]"))),
);
// Add filtering for the bin directory of the base interpreter path
let bin_dir = if cfg!(windows) {
// On Windows, the Python executable is in the root, not the bin directory
executable
.canonicalize()
.unwrap()
.parent()
.unwrap()
.join("Scripts")
} else {
executable
.canonicalize()
.unwrap()
.parent()
.unwrap()
.to_path_buf()
};
filters.extend(
Self::path_patterns(bin_dir)
.into_iter()
.map(|pattern| (pattern.to_string(), format!("[PYTHON-BIN-{version}]"))),
);
// And for the symlink we created in the test the Python path
filters.extend(
Self::path_patterns(python_dir.join(version.to_string()))
+25 -2
View File
@@ -385,7 +385,7 @@ fn find_uv_bin_user_bin() {
#[test]
fn find_uv_bin_error_message() {
let context = TestContext::new("3.12")
let mut context = TestContext::new("3.12")
.with_filtered_python_names()
.with_filtered_virtualenv_bin()
.with_filtered_exe_suffix()
@@ -394,6 +394,29 @@ fn find_uv_bin_error_message() {
// `with_filtered_virtualenv_bin` only filters "Scripts", not "bin"
.with_filter((r"[\\/]bin".to_string(), "/[BIN]".to_string()));
// Add filters for Python bin directories using with_filtered_path
// This inserts at the beginning, so these filters are applied first
let python_info: Vec<_> = context.python_versions.clone();
for (version, executable) in &python_info {
let bin_dir = if cfg!(windows) {
// On Windows, the Python executable is in the root, not the bin directory
executable
.canonicalize()
.unwrap()
.parent()
.unwrap()
.join("Scripts")
} else {
executable
.canonicalize()
.unwrap()
.parent()
.unwrap()
.to_path_buf()
};
context = context.with_filtered_path(&bin_dir, &format!("PYTHON-BIN-{version}"));
}
// Install in a virtual environment
uv_snapshot!(context.filters(), context.pip_install()
.arg(context.workspace_root.join("scripts/packages/fake-uv")), @r"
@@ -431,7 +454,7 @@ fn find_uv_bin_error_message() {
raise UvNotFound(
uv._find_uv.UvNotFound: Could not find the uv binary in any of the following locations:
- [VENV]/[BIN]
- [PYTHON-BIN-3.12]
- [PYTHON-BIN-3.12]/
- [SITE_PACKAGES]/[BIN]
- [USER_SCHEME]/[BIN]
"#