test: make the remaining uv download tests pass without uv installed - #1153
Merged
Conversation
Three tests assert `uv_install_mock.assert_called_once_with(...)` but never
reach the mock on a host without uv: `VirtualEnv._install_python()` checks
`has_uv` first and short-circuits, so the mocked `uv_install_python` is never
called.
if self.venv_backend == "uv":
has_uv, _, uv_ver = _uv_state()
if has_uv and version.Version("0.4.16") <= uv_ver and uv_install_python(...):
Same root cause as wntrblmgh-1046, which wntrblm#1137 fixed for
`test_download_python_failed_install` by pretending uv is available. This
applies that guard to the three sibling tests it did not cover.
wntrblmgh-1045 surfaces as `InterpreterNotFound` rather than wntrblmgh-1046's assertion
error only because `test_download_python_failed_install` already wraps the
call in `pytest.raises`.
Measured on 7519a98, `pytest tests/test_virtualenv.py`:
without uv with uv
before 4 failed, 156 passed 7 failed, 187 passed
after 0 failed, 160 passed 7 failed, 187 passed
The 7 with-uv failures are conda tests, identical before and after; their
cause was not investigated. Removing `HAS_UV` from one of the three guards
turns exactly that test red again.
Fixes wntrblm#1045
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Collaborator
|
Thanks! I swapped the Claude coauthor for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1045. Same root cause as #1046 — three call sites #1137 did not cover.
Reproduction on main @7519a98
Cause
nox/virtualenv.py:941-949:Without uv on the host,
has_uvisFalseand the mockeduv_install_pythonis never reached, so
assert_called_once_with(...)cannot hold.This issue surfaces as
InterpreterNotFoundrather than #1046's assertionerror only because
test_download_python_failed_installalready wraps the callin
pytest.raises. Same short-circuit, different symptom.Change
The guard #1137 added, applied to the three remaining tests that assert
uv_install_mock.assert_called_once_with(...). No production code touched, socoverage is unaffected.
Verification
pytest tests/test_virtualenv.py(whole file):The 7 with-uv failures are conda tests. They are byte-identical before and
after — I diffed the two
FAILEDlists — and I did not investigate theircause, since this change does not touch that path.
Removing
HAS_UVfrom one of the three new guards turns exactly that one testred again, so the guard is load-bearing rather than decorative.
ruff checkandruff format --checkpass on the changed file.