From aeacd07739c21d0a71553225b827a94065494ffe Mon Sep 17 00:00:00 2001 From: Carl George Date: Thu, 29 Aug 2024 21:49:56 -0500 Subject: [PATCH 2/3] 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. (cherry picked from commit ab9acba8dfe009a4ce69ecf4df9fbb1ec8d044c8) --- tests/test_env.py | 18 ++++++++++++++++-- tests/test_integration.py | 10 +++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/test_env.py b/tests/test_env.py index 035457f..1f8f489 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -21,6 +21,7 @@ import build.env IS_PYPY = sys.implementation.name == 'pypy' IS_WINDOWS = sys.platform.startswith('win') +MISSING_UV = not shutil.which('uv') @pytest.mark.isolated @@ -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, @@ -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',), ) @@ -255,7 +262,13 @@ def test_venv_creation( 'installer', [ 'pip', - pytest.param('uv', marks=pytest.mark.xfail(IS_PYPY and IS_WINDOWS, reason='uv cannot find PyPy executable')), + pytest.param( + 'uv', + marks=[ + pytest.mark.xfail(IS_PYPY and IS_WINDOWS, reason='uv cannot find PyPy executable'), + pytest.mark.skipif(MISSING_UV, reason='uv executable not found'), + ] + ), ], ) def test_requirement_installation( @@ -266,6 +279,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, diff --git a/tests/test_integration.py b/tests/test_integration.py index 341c1d4..8e070a5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -18,6 +18,7 @@ import build.__main__ IS_WINDOWS = sys.platform.startswith('win') IS_PYPY = sys.implementation.name == 'pypy' +MISSING_UV = not shutil.which('uv') INTEGRATION_SOURCES = { @@ -78,7 +79,14 @@ def get_project(name, tmp_path): ) @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( -- 2.46.0