Skip to content

Commit

Permalink
Add test coverage for --python-version overriding UV_PYTHON entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Feb 13, 2025
1 parent f412685 commit 0c0c0c6
Showing 1 changed file with 57 additions and 26 deletions.
83 changes: 57 additions & 26 deletions crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,13 +1737,14 @@ fn compile_python_build_version_different_than_target() -> Result<()> {
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.env(EnvVars::UV_PYTHON, "3.11")
.arg("-p")
.arg("[email protected]")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-version 3.12
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-version 3.12 -p [email protected]
black==23.10.[X]
# via -r requirements.in
click==8.1.7
Expand All @@ -1762,18 +1763,51 @@ fn compile_python_build_version_different_than_target() -> Result<()> {
"###
);

// If we can't find the interpreter, we fail
uv_snapshot!(context.filters(), context.pip_compile()
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.arg("-p")
.arg("[email protected]")
.arg("[email protected]")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found for PyPy 3.11 in [PYTHON SOURCES]
"###
);

uv_snapshot!(context.filters(), context.pip_compile()
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.arg("-p")
.arg("3.13")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found for Python 3.13 in [PYTHON SOURCES]
"###
);

// `UV_PYTHON` is ignored if `--python-version` is set
uv_snapshot!(context.filters(), context.pip_compile()
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.env(EnvVars::UV_PYTHON, "3.11")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-version 3.12 -p [email protected]
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-version 3.12
black==23.10.[X]
# via -r requirements.in
click==8.1.7
Expand All @@ -1792,36 +1826,33 @@ fn compile_python_build_version_different_than_target() -> Result<()> {
"###
);

// If we can't find the interpreter, we fail
uv_snapshot!(context.filters(), context.pip_compile()
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.arg("-p")
.arg("[email protected]")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No interpreter found for PyPy 3.11 in [PYTHON SOURCES]
"###
);

// `UV_PYTHON` is ignored if `--python-version` is set
uv_snapshot!(context.filters(), context.pip_compile()
.arg("requirements.in")
.arg("--python-version")
.arg("3.12")
.arg("-p")
.arg("3.13")
.env(EnvVars::UV_PYTHON, "pypy")
.env_remove(EnvVars::VIRTUAL_ENV), @r###"
success: false
exit_code: 2
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --python-version 3.12
black==23.10.[X]
# via -r requirements.in
click==8.1.7
# via black
mypy-extensions==1.0.0
# via black
packaging==24.0
# via black
pathspec==0.12.1
# via black
platformdirs==4.2.0
# via black
----- stderr -----
error: No interpreter found for Python 3.13 in [PYTHON SOURCES]
Resolved 6 packages in [TIME]
"###
);

Expand Down

0 comments on commit 0c0c0c6

Please sign in to comment.