summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2020-05-08 08:53:59 +0200
committerGitHub <noreply@github.com>2020-05-08 08:53:59 +0200
commit6ad91d0085acc8091f2336faaf4710c1bae4cf18 (patch)
treed3c1373efa1731a81262eb596221aa22b6897400
parente7f0b4bfd9a1f86ba946469a91b6261366bc5f3e (diff)
parent968aac09663bcee8dfaee8c894ba4a723df9a172 (diff)
downloadsetuptools-scm-6ad91d0085acc8091f2336faaf4710c1bae4cf18.tar.gz
Merge pull request #429 from mgorny/skip-git
Skip git tests when git is unavailable
-rw-r--r--testing/test_file_finder.py5
-rw-r--r--testing/test_git.py9
-rw-r--r--testing/test_integration.py6
-rw-r--r--testing/test_regressions.py10
4 files changed, 24 insertions, 6 deletions
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):