Update some Python find tests to use filters (#12377)

This commit is contained in:
Zanie Blue 2025-03-21 13:44:30 -05:00 committed by GitHub
parent 2592e0ff1a
commit 42a87da857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 37 deletions

View File

@ -9,28 +9,18 @@ use crate::common::{uv_snapshot, venv_bin_path, TestContext};
#[test]
fn python_find() {
let mut context: TestContext = TestContext::new_with_versions(&["3.11", "3.12"]);
let mut context: TestContext =
TestContext::new_with_versions(&["3.11", "3.12"]).with_filtered_python_sources();
// No interpreters on the path
if cfg!(windows) {
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::UV_TEST_PYTHON_PATH, ""), @r###"
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::UV_TEST_PYTHON_PATH, ""), @r"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found in virtual environments, managed installations, search path, or registry
"###);
} else {
uv_snapshot!(context.filters(), context.python_find().env(EnvVars::UV_TEST_PYTHON_PATH, ""), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found in virtual environments, managed installations, or search path
"###);
}
error: No interpreter found in [PYTHON SOURCES]
");
// We find the first interpreter on the path
uv_snapshot!(context.filters(), context.python_find(), @r###"
@ -108,25 +98,14 @@ fn python_find() {
"###);
// Request PyPy (which should be missing)
if cfg!(windows) {
uv_snapshot!(context.filters(), context.python_find().arg("pypy"), @r###"
uv_snapshot!(context.filters(), context.python_find().arg("pypy"), @r"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found for PyPy in virtual environments, managed installations, search path, or registry
"###);
} else {
uv_snapshot!(context.filters(), context.python_find().arg("pypy"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found for PyPy in virtual environments, managed installations, or search path
"###);
}
error: No interpreter found for PyPy in [PYTHON SOURCES]
");
// Swap the order of the Python versions
context.python_versions.reverse();