Reject accidental PyPI access in local-scenario tests #1885
<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
Merging this PR will not alter performance
✅ 41 untouched benchmarks
---
<sub>Comparing <code>zb/packse-review-test-network-policy</code> (ff32539) with <code>zb/packse-simplify-scenarios</code> (ec6263f)[^unexpected-base]</sub>
<a href="https://app.codspeed.io/astral-sh/uv-dev/branches/zb%2Fpackse-review-test-network-policy?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>
[^unexpected-base]: No successful run was found on <code>zb/packse-simplify-scenarios</code> (bfeb735) during the generation of this report, so 1b9d8d6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
It seems like this should be a #[cfg(test)] variant?
Same here.
Or whatever works across crate boundaries.
This seems like it belongs in a different PR and should have a better name.
This is now the final hardening layer. The error variant, policy fields, middleware, and redirect checks are behind #[cfg(any(test, feature = "test"))]. uv-test enables the uv-client/test feature so the policy also works across crate boundaries in integration-test binaries; ordinary client builds omit it.
The builder and client fields now use the same test-only configuration as the middleware and error variant.
Moved this to #1936 and renamed it UV_INTERNAL__TEST_VIRTUALENV_DISCOVERY_ROOT. That PR includes a focused case showing that discovery stops before the test root while still finding a virtualenv inside it.
woodruffw
zaniebot
After the test suite defaults to local package indexes, accidental public-index access should fail instead of silently reintroducing a PyPI dependency. Add a test-only
uv-clientpolicy that rejects public-index requests and redirect targets, rebuilds reused clients when their policy differs, and rejects opaque custom clients that cannot enforce it. Enable the policy for local test commands and artifact helpers, with an explicit opt-out for the dedicated PyPI cases.test_pypi_guard_blocks_requests_and_redirectscovers both redirect modes;test_pypi_guard_rebuilds_reused_clientscovers client reuse. This is the final hardening layer, after #1685 and #1693.