Skip to content

Commit 968aac0

Browse files
committed
Skip git tests when git is unavailable
1 parent e7f0b4b commit 968aac0

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

testing/test_file_finder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
@pytest.fixture(params=["git", "hg"])
1010
def inwd(request, wd, monkeypatch):
1111
if request.param == "git":
12-
wd("git init")
12+
try:
13+
wd("git init")
14+
except FileNotFoundError:
15+
pytest.skip("git executable not found")
1316
wd("git config user.email [email protected]")
1417
wd('git config user.name "a test"')
1518
wd.add_command = "git add ."

testing/test_git.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import sys
22

33
from setuptools_scm import integration
4-
from setuptools_scm.utils import do
4+
from setuptools_scm.utils import do, has_command
55
from setuptools_scm import git
66
import pytest
77
from datetime import datetime
88
from os.path import join as opj
99
from setuptools_scm.file_finder_git import git_find_files
10+
import warnings
11+
12+
13+
with warnings.catch_warnings():
14+
warnings.filterwarnings("ignore")
15+
if not has_command("git"):
16+
pytestmark = pytest.mark.skip(reason="git executable not found")
1017

1118

1219
@pytest.fixture

testing/test_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
@pytest.fixture
99
def wd(wd):
10-
wd("git init")
10+
try:
11+
wd("git init")
12+
except FileNotFoundError:
13+
pytest.skip("git executable not found")
14+
1115
wd("git config user.email [email protected]")
1216
wd('git config user.name "a test"')
1317
wd.add_command = "git add ."

testing/test_regressions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ def test_pkginfo_noscmroot(tmpdir, monkeypatch):
2727
res = do((sys.executable, "setup.py", "--version"), p)
2828
assert res == "1.0"
2929

30-
do("git init", p.dirpath())
31-
res = do((sys.executable, "setup.py", "--version"), p)
32-
assert res == "0.1.dev0"
30+
try:
31+
do("git init", p.dirpath())
32+
except FileNotFoundError:
33+
pass
34+
else:
35+
res = do((sys.executable, "setup.py", "--version"), p)
36+
assert res == "0.1.dev0"
3337

3438

3539
def test_pip_egg_info(tmpdir, monkeypatch):

0 commit comments

Comments
 (0)