From 968aac09663bcee8dfaee8c894ba4a723df9a172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Thu, 7 May 2020 21:26:48 +0200 Subject: Skip git tests when git is unavailable --- testing/test_file_finder.py | 5 ++++- testing/test_git.py | 9 ++++++++- testing/test_integration.py | 6 +++++- testing/test_regressions.py | 10 +++++++--- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'testing') diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index d7b6d11..e5c2437 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -9,7 +9,10 @@ from setuptools_scm.integration import find_files @pytest.fixture(params=["git", "hg"]) def inwd(request, wd, monkeypatch): if request.param == "git": - wd("git init") + try: + wd("git init") + except FileNotFoundError: + pytest.skip("git executable not found") wd("git config user.email test@example.com") wd('git config user.name "a test"') wd.add_command = "git add ." diff --git a/testing/test_git.py b/testing/test_git.py index 2e86efb..e485fc7 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -1,12 +1,19 @@ import sys from setuptools_scm import integration -from setuptools_scm.utils import do +from setuptools_scm.utils import do, has_command from setuptools_scm import git import pytest from datetime import datetime from os.path import join as opj from setuptools_scm.file_finder_git import git_find_files +import warnings + + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + if not has_command("git"): + pytestmark = pytest.mark.skip(reason="git executable not found") @pytest.fixture diff --git a/testing/test_integration.py b/testing/test_integration.py index a01ac8b..1c291db 100644 --- a/testing/test_integration.py +++ b/testing/test_integration.py @@ -7,7 +7,11 @@ from setuptools_scm.utils import do @pytest.fixture def wd(wd): - wd("git init") + try: + wd("git init") + except FileNotFoundError: + pytest.skip("git executable not found") + wd("git config user.email test@example.com") wd('git config user.name "a test"') wd.add_command = "git add ." diff --git a/testing/test_regressions.py b/testing/test_regressions.py index f3b0fc6..0ac255e 100644 --- a/testing/test_regressions.py +++ b/testing/test_regressions.py @@ -27,9 +27,13 @@ def test_pkginfo_noscmroot(tmpdir, monkeypatch): res = do((sys.executable, "setup.py", "--version"), p) assert res == "1.0" - do("git init", p.dirpath()) - res = do((sys.executable, "setup.py", "--version"), p) - assert res == "0.1.dev0" + try: + do("git init", p.dirpath()) + except FileNotFoundError: + pass + else: + res = do((sys.executable, "setup.py", "--version"), p) + assert res == "0.1.dev0" def test_pip_egg_info(tmpdir, monkeypatch): -- cgit v1.2.1