Skip to content

Commit

Permalink
tests: optional uv
Browse files Browse the repository at this point in the history
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
  • Loading branch information
carlwgeorge authored and henryiii committed Sep 5, 2024
1 parent 553b700 commit 980d04b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
20 changes: 16 additions & 4 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

IS_PYPY = sys.implementation.name == 'pypy'
IS_WINDOWS = sys.platform.startswith('win')
MISSING_UV = not shutil.which('uv')


@pytest.mark.isolated
Expand Down Expand Up @@ -206,6 +207,7 @@ def test_default_impl_install_cmd_well_formed(

@pytest.mark.parametrize('verbosity', range(4))
@pytest.mark.skipif(IS_PYPY, reason='uv cannot find PyPy executable')
@pytest.mark.skipif(MISSING_UV, reason='uv executable not found')
def test_uv_impl_install_cmd_well_formed(
mocker: pytest_mock.MockerFixture,
verbosity: int,
Expand Down Expand Up @@ -237,7 +239,12 @@ def test_uv_impl_install_cmd_well_formed(
('pip', 'venv+pip', False),
('pip', 'virtualenv+pip', True),
('pip', 'virtualenv+pip', None), # Fall-through
('uv', 'venv+uv', None),
pytest.param(
'uv',
'venv+uv',
None,
marks=pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
),
],
indirect=('has_virtualenv',),
)
Expand All @@ -257,9 +264,13 @@ def test_venv_creation(
'pip',
pytest.param(
'uv',
marks=pytest.mark.xfail(
IS_PYPY and IS_WINDOWS and sys.version_info < (3, 9), reason='uv cannot find PyPy 3.8 executable on Windows'
),
marks=[
pytest.mark.xfail(
IS_PYPY and IS_WINDOWS and sys.version_info < (3, 9),
reason='uv cannot find PyPy 3.8 executable on Windows',
),
pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
],
),
],
)
Expand All @@ -271,6 +282,7 @@ def test_requirement_installation(
env.install([f'test-flit @ {Path(package_test_flit).as_uri()}'])


@pytest.mark.skipif(MISSING_UV, reason='uv executable not found')
def test_external_uv_detection_success(
caplog: pytest.LogCaptureFixture,
mocker: pytest_mock.MockerFixture,
Expand Down
10 changes: 9 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

IS_WINDOWS = sys.platform.startswith('win')
IS_PYPY = sys.implementation.name == 'pypy'
MISSING_UV = not shutil.which('uv')


INTEGRATION_SOURCES = {
Expand Down Expand Up @@ -79,7 +80,14 @@ def _ignore_folder(base, filenames):
)
@pytest.mark.parametrize(
'args',
[[], ['--installer', 'uv'], ['-x', '--no-isolation']],
[
[],
pytest.param(
['--installer', 'uv'],
marks=pytest.mark.skipif(MISSING_UV, reason='uv executable not found'),
),
['-x', '--no-isolation'],
],
ids=['isolated_pip', 'isolated_uv', 'no_isolation'],
)
@pytest.mark.parametrize(
Expand Down

0 comments on commit 980d04b

Please sign in to comment.