Skip to content

Commit 73829f3

Browse files
Conditionalize more tests that require PyPI (#13699)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Use the existing `pypi` feature to conditionalize a number of tests that attempt to access https://pypi.org and/or https://files.pythonhosted.org. See #8970 (comment). There is no reason to believe that these are *all* of the tests that need to be conditionalized on the `pypi` feature, but this should be a solid step in the right direction. ## Test Plan <!-- How was it tested? --> This allows me to build and run the integration tests in [Fedora’s `uv` package](https://src.fedoraproject.org/rpms/uv) without having to manually skip tests that try to access PyPI. I confirmed that this appears to accomplish that goal. Otherwise, this should be tested by building and running the tests as usual. As mentioned in #8970 (comment), a more complete solution would include CI tests that confirm these features are working as intended. I’m not in a position to offer that.
1 parent 1e890b5 commit 73829f3

File tree

10 files changed

+75
-2
lines changed

10 files changed

+75
-2
lines changed

crates/uv/tests/it/branching_urls.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::common::{TestContext, make_project, uv_snapshot};
1414
/// ]
1515
/// ```
1616
#[test]
17+
#[cfg(feature = "pypi")]
1718
fn branching_urls_disjoint() -> Result<()> {
1819
let context = TestContext::new("3.12");
1920

@@ -47,6 +48,7 @@ fn branching_urls_disjoint() -> Result<()> {
4748
/// ]
4849
/// ```
4950
#[test]
51+
#[cfg(feature = "pypi")]
5052
fn branching_urls_overlapping() -> Result<()> {
5153
let context = TestContext::new("3.12");
5254

@@ -83,6 +85,7 @@ fn branching_urls_overlapping() -> Result<()> {
8385
/// a -> b -> b2 -> https://../iniconfig-2.0.0-py3-none-any.whl
8486
/// ```
8587
#[test]
88+
#[cfg(feature = "pypi")]
8689
fn root_package_splits_but_transitive_conflict() -> Result<()> {
8790
let context = TestContext::new("3.12");
8891

@@ -151,6 +154,7 @@ fn root_package_splits_but_transitive_conflict() -> Result<()> {
151154
/// a -> b -> b2 ; python_version >= '3.12' -> https://../iniconfig-2.0.0-py3-none-any.whl
152155
/// ```
153156
#[test]
157+
#[cfg(feature = "pypi")]
154158
fn root_package_splits_transitive_too() -> Result<()> {
155159
let context = TestContext::new("3.12");
156160

@@ -356,6 +360,7 @@ fn root_package_splits_transitive_too() -> Result<()> {
356360
/// a -> b2 ; python_version >= '3.12' -> iniconfig==2.0.0
357361
/// ```
358362
#[test]
363+
#[cfg(feature = "pypi")]
359364
fn root_package_splits_other_dependencies_too() -> Result<()> {
360365
let context = TestContext::new("3.12");
361366

@@ -539,6 +544,7 @@ fn root_package_splits_other_dependencies_too() -> Result<()> {
539544
/// ]
540545
/// ```
541546
#[test]
547+
#[cfg(feature = "pypi")]
542548
fn branching_between_registry_and_direct_url() -> Result<()> {
543549
let context = TestContext::new("3.12");
544550

@@ -624,7 +630,7 @@ fn branching_between_registry_and_direct_url() -> Result<()> {
624630
/// ]
625631
/// ```
626632
#[test]
627-
#[cfg(feature = "git")]
633+
#[cfg(all(feature = "git", feature = "pypi"))]
628634
fn branching_urls_of_different_sources_disjoint() -> Result<()> {
629635
let context = TestContext::new("3.12");
630636

@@ -708,7 +714,7 @@ fn branching_urls_of_different_sources_disjoint() -> Result<()> {
708714
/// ]
709715
/// ```
710716
#[test]
711-
#[cfg(feature = "git")]
717+
#[cfg(all(feature = "git", feature = "pypi"))]
712718
fn branching_urls_of_different_sources_conflict() -> Result<()> {
713719
let context = TestContext::new("3.12");
714720

crates/uv/tests/it/build_backend.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const BUILT_BY_UV_TEST_SCRIPT: &str = indoc! {r#"
2424
///
2525
/// We can't test end-to-end here including the PEP 517 bridge code since we don't have a uv wheel.
2626
#[test]
27+
#[cfg(feature = "pypi")]
2728
fn built_by_uv_direct_wheel() -> Result<()> {
2829
let context = TestContext::new("3.12");
2930
let built_by_uv = Path::new("../../scripts/packages/built-by-uv");
@@ -83,6 +84,7 @@ fn built_by_uv_direct_wheel() -> Result<()> {
8384
/// We can't test end-to-end here including the PEP 517 bridge code since we don't have a uv wheel,
8485
/// so we call the build backend directly.
8586
#[test]
87+
#[cfg(feature = "pypi")]
8688
fn built_by_uv_direct() -> Result<()> {
8789
let context = TestContext::new("3.12");
8890
let built_by_uv = Path::new("../../scripts/packages/built-by-uv");
@@ -160,6 +162,7 @@ fn built_by_uv_direct() -> Result<()> {
160162
/// We can't test end-to-end here including the PEP 517 bridge code since we don't have a uv wheel,
161163
/// so we call the build backend directly.
162164
#[test]
165+
#[cfg(feature = "pypi")]
163166
fn built_by_uv_editable() -> Result<()> {
164167
let context = TestContext::new("3.12");
165168
let built_by_uv = Path::new("../../scripts/packages/built-by-uv");

crates/uv/tests/it/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mod lock_scenarios;
4141

4242
mod version;
4343

44+
#[cfg(all(feature = "python", feature = "pypi"))]
4445
mod pip_check;
4546

4647
#[cfg(all(feature = "python", feature = "pypi"))]

crates/uv/tests/it/pip_list.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn list_empty_json() {
5656
}
5757

5858
#[test]
59+
#[cfg(feature = "pypi")]
5960
fn list_single_no_editable() -> Result<()> {
6061
let context = TestContext::new("3.12");
6162

@@ -96,6 +97,7 @@ fn list_single_no_editable() -> Result<()> {
9697
}
9798

9899
#[test]
100+
#[cfg(feature = "pypi")]
99101
fn list_outdated_columns() -> Result<()> {
100102
let context = TestContext::new("3.12");
101103

@@ -136,6 +138,7 @@ fn list_outdated_columns() -> Result<()> {
136138
}
137139

138140
#[test]
141+
#[cfg(feature = "pypi")]
139142
fn list_outdated_json() -> Result<()> {
140143
let context = TestContext::new("3.12");
141144

@@ -232,6 +235,7 @@ fn list_outdated_git() -> Result<()> {
232235
}
233236

234237
#[test]
238+
#[cfg(feature = "pypi")]
235239
fn list_outdated_index() -> Result<()> {
236240
let context = TestContext::new("3.12");
237241

@@ -275,6 +279,7 @@ fn list_outdated_index() -> Result<()> {
275279
}
276280

277281
#[test]
282+
#[cfg(feature = "pypi")]
278283
fn list_editable() {
279284
let context = TestContext::new("3.12");
280285

@@ -320,6 +325,7 @@ fn list_editable() {
320325
}
321326

322327
#[test]
328+
#[cfg(feature = "pypi")]
323329
fn list_editable_only() {
324330
let context = TestContext::new("3.12");
325331

@@ -394,6 +400,7 @@ fn list_editable_only() {
394400
}
395401

396402
#[test]
403+
#[cfg(feature = "pypi")]
397404
fn list_exclude() {
398405
let context = TestContext::new("3.12");
399406

@@ -475,6 +482,7 @@ fn list_exclude() {
475482
}
476483

477484
#[test]
485+
#[cfg(feature = "pypi")]
478486
#[cfg(not(windows))]
479487
fn list_format_json() {
480488
let context = TestContext::new("3.12");
@@ -541,6 +549,7 @@ fn list_format_json() {
541549
}
542550

543551
#[test]
552+
#[cfg(feature = "pypi")]
544553
fn list_format_freeze() {
545554
let context = TestContext::new("3.12");
546555

@@ -706,6 +715,7 @@ Version: 0.1-bulbasaur
706715
}
707716

708717
#[test]
718+
#[cfg(feature = "pypi")]
709719
fn list_ignores_quiet_flag_format_freeze() {
710720
let context = TestContext::new("3.12");
711721

crates/uv/tests/it/pip_show.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fn show_empty() {
2626
}
2727

2828
#[test]
29+
#[cfg(feature = "pypi")]
2930
fn show_requires_multiple() -> Result<()> {
3031
let context = TestContext::new("3.12");
3132

@@ -75,6 +76,7 @@ fn show_requires_multiple() -> Result<()> {
7576
/// Asserts that the Python version marker in the metadata is correctly evaluated.
7677
/// `click` v8.1.7 requires `importlib-metadata`, but only when `python_version < "3.8"`.
7778
#[test]
79+
#[cfg(feature = "pypi")]
7880
fn show_python_version_marker() -> Result<()> {
7981
let context = TestContext::new("3.12");
8082

@@ -124,6 +126,7 @@ fn show_python_version_marker() -> Result<()> {
124126
}
125127

126128
#[test]
129+
#[cfg(feature = "pypi")]
127130
fn show_found_single_package() -> Result<()> {
128131
let context = TestContext::new("3.12");
129132

@@ -168,6 +171,7 @@ fn show_found_single_package() -> Result<()> {
168171
}
169172

170173
#[test]
174+
#[cfg(feature = "pypi")]
171175
fn show_found_multiple_packages() -> Result<()> {
172176
let context = TestContext::new("3.12");
173177

@@ -224,6 +228,7 @@ fn show_found_multiple_packages() -> Result<()> {
224228
}
225229

226230
#[test]
231+
#[cfg(feature = "pypi")]
227232
fn show_found_one_out_of_three() -> Result<()> {
228233
let context = TestContext::new("3.12");
229234

@@ -276,6 +281,7 @@ fn show_found_one_out_of_three() -> Result<()> {
276281
}
277282

278283
#[test]
284+
#[cfg(feature = "pypi")]
279285
fn show_found_one_out_of_two_quiet() -> Result<()> {
280286
let context = TestContext::new("3.12");
281287

@@ -323,6 +329,7 @@ fn show_found_one_out_of_two_quiet() -> Result<()> {
323329
}
324330

325331
#[test]
332+
#[cfg(feature = "pypi")]
326333
fn show_empty_quiet() -> Result<()> {
327334
let context = TestContext::new("3.12");
328335

@@ -369,6 +376,7 @@ fn show_empty_quiet() -> Result<()> {
369376
}
370377

371378
#[test]
379+
#[cfg(feature = "pypi")]
372380
fn show_editable() -> Result<()> {
373381
let context = TestContext::new("3.12");
374382

@@ -405,6 +413,7 @@ fn show_editable() -> Result<()> {
405413
}
406414

407415
#[test]
416+
#[cfg(feature = "pypi")]
408417
fn show_required_by_multiple() -> Result<()> {
409418
let context = TestContext::new("3.12");
410419

@@ -460,6 +469,7 @@ fn show_required_by_multiple() -> Result<()> {
460469
}
461470

462471
#[test]
472+
#[cfg(feature = "pypi")]
463473
fn show_files() {
464474
let context = TestContext::new("3.12");
465475

0 commit comments

Comments
 (0)