diff --git a/tests/backend/builders/test_binary.py b/tests/backend/builders/test_binary.py index cce31c6a6..410146a11 100644 --- a/tests/backend/builders/test_binary.py +++ b/tests/backend/builders/test_binary.py @@ -13,6 +13,8 @@ from hatchling.builders.binary import BinaryBuilder from hatchling.builders.plugin.interface import BuilderInterface +pytestmark = [pytest.mark.requires_cargo, pytest.mark.requires_internet] + class ExpectedEnvVars: def __init__(self, env_vars: dict): diff --git a/tests/cli/publish/test_publish.py b/tests/cli/publish/test_publish.py index 2df3844de..30bb3d7aa 100644 --- a/tests/cli/publish/test_publish.py +++ b/tests/cli/publish/test_publish.py @@ -8,7 +8,12 @@ from hatch.config.constants import PublishEnvVars -pytestmark = [pytest.mark.usefixtures('devpi'), pytest.mark.usefixtures('local_backend_process')] +pytestmark = [ + pytest.mark.requires_docker, + pytest.mark.requires_internet, + pytest.mark.usefixtures('devpi'), + pytest.mark.usefixtures('local_backend_process'), +] @pytest.fixture(autouse=True) diff --git a/tests/conftest.py b/tests/conftest.py index 7cccee097..e8fe663a5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -458,9 +458,15 @@ def pytest_runtest_setup(item): if marker.name == 'requires_unix' and PLATFORM.windows: pytest.skip('Not running on a Linux-based platform') - if marker.name == 'requires_git' and not shutil.which('git'): # no cov + if marker.name == 'requires_git' and not git_available(): # no cov pytest.skip('Git not present in the environment') + if marker.name == 'requires_docker' and not docker_available(): # no cov + pytest.skip('Docker not present in the environment') + + if marker.name == 'requires_cargo' and not cargo_available(): # no cov + pytest.skip('Cargo not present in the environment') + def pytest_configure(config): config.addinivalue_line('markers', 'requires_windows: Tests intended for Windows operating systems') @@ -469,6 +475,12 @@ def pytest_configure(config): config.addinivalue_line('markers', 'requires_unix: Tests intended for Linux-based operating systems') config.addinivalue_line('markers', 'requires_internet: Tests that require access to the internet') config.addinivalue_line('markers', 'requires_git: Tests that require the git command available in the environment') + config.addinivalue_line( + 'markers', 'requires_docker: Tests that require the docker command available in the environment' + ) + config.addinivalue_line( + 'markers', 'requires_cargo: Tests that require the cargo command available in the environment' + ) config.addinivalue_line('markers', 'allow_backend_process: Force the use of backend communication') @@ -491,3 +503,27 @@ def network_connectivity(): # no cov return True return False + + +@lru_cache +def git_available(): # no cov + if running_in_ci(): + return True + + return shutil.which('git') is not None + + +@lru_cache +def docker_available(): # no cov + if running_in_ci(): + return True + + return shutil.which('docker') is not None + + +@lru_cache +def cargo_available(): # no cov + if running_in_ci(): + return True + + return shutil.which('cargo') is not None