Skip to content

Commit ab9acba

Browse files
committed
tests: optional uv
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.
1 parent 562907e commit ab9acba

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

tests/test_env.py

Lines changed: 16 additions & 2 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
)
@@ -255,7 +262,13 @@ def test_venv_creation(
255262
'installer',
256263
[
257264
'pip',
258-
pytest.param('uv', marks=pytest.mark.xfail(IS_PYPY and IS_WINDOWS, reason='uv cannot find PyPy executable')),
265+
pytest.param(
266+
'uv',
267+
marks=[
268+
pytest.mark.xfail(IS_PYPY and IS_WINDOWS, reason='uv cannot find PyPy executable'),
269+
pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
270+
]
271+
),
259272
],
260273
)
261274
def test_requirement_installation(
@@ -266,6 +279,7 @@ def test_requirement_installation(
266279
env.install([f'test-flit @ {Path(package_test_flit).as_uri()}'])
267280

268281

282+
@pytest.mark.skipif(MISSING_UV, reason='uv executable not found')
269283
def test_external_uv_detection_success(
270284
caplog: pytest.LogCaptureFixture,
271285
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 = {
@@ -78,7 +79,14 @@ def _ignore_folder(base, filenames):
7879
)
7980
@pytest.mark.parametrize(
8081
'args',
81-
[[], ['--installer', 'uv'], ['-x', '--no-isolation']],
82+
[
83+
[],
84+
pytest.param(
85+
['--installer', 'uv'],
86+
marks=pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
87+
),
88+
['-x', '--no-isolation']
89+
],
8290
ids=['isolated_pip', 'isolated_uv', 'no_isolation'],
8391
)
8492
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)