Skip to content

Commit 2e68517

Browse files
committed
Skip scm tests if the command is not installed
1 parent 697c23d commit 2e68517

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

tests/test_cli/test_bump.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,18 @@ def test_cli_options_override_config(tmp_path: Path, fixtures_path: Path, mocker
155155
@pytest.mark.parametrize(
156156
["repo", "scm_command"],
157157
[
158-
param("git_repo", "git", id="git"),
159-
param("hg_repo", "hg", id="hg"),
158+
param(
159+
"git_repo",
160+
"git",
161+
id="git",
162+
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
163+
),
164+
param(
165+
"hg_repo",
166+
"hg",
167+
id="hg",
168+
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
169+
),
160170
],
161171
)
162172
def test_dirty_work_dir_raises_error(repo: str, scm_command: str, request, runner):

tests/test_scm.py

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests of the VCS module."""
22

33
import logging
4+
import shutil
45
import subprocess
56
from pathlib import Path
67

@@ -176,6 +177,7 @@ def test_hg_is_not_usable(tmp_path: Path) -> None:
176177
assert not scm.Mercurial.is_usable()
177178

178179

180+
@pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available.")
179181
def test_hg_is_usable(hg_repo: Path) -> None:
180182
"""Should return false if it is not a mercurial repo."""
181183
with inside_dir(hg_repo):
@@ -185,8 +187,20 @@ def test_hg_is_usable(hg_repo: Path) -> None:
185187
@pytest.mark.parametrize(
186188
["repo", "scm_command", "scm_class"],
187189
[
188-
param("git_repo", "git", scm.Git, id="git"),
189-
param("hg_repo", "hg", scm.Mercurial, id="hg"),
190+
param(
191+
"git_repo",
192+
"git",
193+
scm.Git,
194+
id="git",
195+
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
196+
),
197+
param(
198+
"hg_repo",
199+
"hg",
200+
scm.Mercurial,
201+
id="hg",
202+
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
203+
),
190204
],
191205
)
192206
def test_commit_and_tag_from_below_scm_root(repo: str, scm_command: str, scm_class: scm.SourceCodeManager, request):
@@ -226,8 +240,20 @@ def test_commit_and_tag_from_below_scm_root(repo: str, scm_command: str, scm_cla
226240
@pytest.mark.parametrize(
227241
["repo", "scm_command", "scm_class"],
228242
[
229-
param("git_repo", "git", scm.Git, id="git"),
230-
param("hg_repo", "hg", scm.Mercurial, id="hg"),
243+
param(
244+
"git_repo",
245+
"git",
246+
scm.Git,
247+
id="git",
248+
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
249+
),
250+
param(
251+
"hg_repo",
252+
"hg",
253+
scm.Mercurial,
254+
id="hg",
255+
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
256+
),
231257
],
232258
)
233259
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)