Skip to content

Commit 9a52c50

Browse files
authored
tests: optional uv (#807)
Skip the tests that need uv when uv is not installed. This makes it easier for Linux distros that package build to avoid a build-time dependency on uv. Update tests/test_env.py
1 parent 553b700 commit 9a52c50

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

tests/test_env.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
IS_PYPY = sys.implementation.name == 'pypy'
2323
IS_WINDOWS = sys.platform.startswith('win')
24+
MISSING_UV = not shutil.which('uv')
2425

2526

2627
@pytest.mark.isolated
@@ -206,6 +207,7 @@ def test_default_impl_install_cmd_well_formed(
206207

207208
@pytest.mark.parametrize('verbosity', range(4))
208209
@pytest.mark.skipif(IS_PYPY, reason='uv cannot find PyPy executable')
210+
@pytest.mark.skipif(MISSING_UV, reason='uv executable not found')
209211
def test_uv_impl_install_cmd_well_formed(
210212
mocker: pytest_mock.MockerFixture,
211213
verbosity: int,
@@ -237,7 +239,12 @@ def test_uv_impl_install_cmd_well_formed(
237239
('pip', 'venv+pip', False),
238240
('pip', 'virtualenv+pip', True),
239241
('pip', 'virtualenv+pip', None), # Fall-through
240-
('uv', 'venv+uv', None),
242+
pytest.param(
243+
'uv',
244+
'venv+uv',
245+
None,
246+
marks=pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
247+
),
241248
],
242249
indirect=('has_virtualenv',),
243250
)
@@ -257,9 +264,13 @@ def test_venv_creation(
257264
'pip',
258265
pytest.param(
259266
'uv',
260-
marks=pytest.mark.xfail(
261-
IS_PYPY and IS_WINDOWS and sys.version_info < (3, 9), reason='uv cannot find PyPy 3.8 executable on Windows'
262-
),
267+
marks=[
268+
pytest.mark.xfail(
269+
IS_PYPY and IS_WINDOWS and sys.version_info < (3, 9),
270+
reason='uv cannot find PyPy 3.8 executable on Windows',
271+
),
272+
pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
273+
],
263274
),
264275
],
265276
)
@@ -271,6 +282,7 @@ def test_requirement_installation(
271282
env.install([f'test-flit @ {Path(package_test_flit).as_uri()}'])
272283

273284

285+
@pytest.mark.skipif(MISSING_UV, reason='uv executable not found')
274286
def test_external_uv_detection_success(
275287
caplog: pytest.LogCaptureFixture,
276288
mocker: pytest_mock.MockerFixture,

tests/test_integration.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
IS_WINDOWS = sys.platform.startswith('win')
2020
IS_PYPY = sys.implementation.name == 'pypy'
21+
MISSING_UV = not shutil.which('uv')
2122

2223

2324
INTEGRATION_SOURCES = {
@@ -79,7 +80,14 @@ def _ignore_folder(base, filenames):
7980
)
8081
@pytest.mark.parametrize(
8182
'args',
82-
[[], ['--installer', 'uv'], ['-x', '--no-isolation']],
83+
[
84+
[],
85+
pytest.param(
86+
['--installer', 'uv'],
87+
marks=pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
88+
),
89+
['-x', '--no-isolation'],
90+
],
8391
ids=['isolated_pip', 'isolated_uv', 'no_isolation'],
8492
)
8593
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)