Skip to content

Commit

Permalink
Merge pull request #248 from ziima/skip-scm-tests
Browse files Browse the repository at this point in the history
Skip scm tests if the command is not installed
  • Loading branch information
coordt authored Oct 26, 2024
2 parents 09c5605 + f9baa28 commit efab98d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
14 changes: 12 additions & 2 deletions tests/test_cli/test_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,18 @@ def test_cli_options_override_config(tmp_path: Path, fixtures_path: Path, mocker
@pytest.mark.parametrize(
["repo", "scm_command"],
[
param("git_repo", "git", id="git"),
param("hg_repo", "hg", id="hg"),
param(
"git_repo",
"git",
id="git",
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
),
param(
"hg_repo",
"hg",
id="hg",
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
),
],
)
def test_dirty_work_dir_raises_error(repo: str, scm_command: str, request, runner):
Expand Down
34 changes: 30 additions & 4 deletions tests/test_scm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests of the VCS module."""

import logging
import shutil
import subprocess
from pathlib import Path

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


@pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available.")
def test_hg_is_usable(hg_repo: Path) -> None:
"""Should return false if it is not a mercurial repo."""
with inside_dir(hg_repo):
Expand All @@ -185,8 +187,20 @@ def test_hg_is_usable(hg_repo: Path) -> None:
@pytest.mark.parametrize(
["repo", "scm_command", "scm_class"],
[
param("git_repo", "git", scm.Git, id="git"),
param("hg_repo", "hg", scm.Mercurial, id="hg"),
param(
"git_repo",
"git",
scm.Git,
id="git",
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
),
param(
"hg_repo",
"hg",
scm.Mercurial,
id="hg",
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
),
],
)
def test_commit_and_tag_from_below_scm_root(repo: str, scm_command: str, scm_class: scm.SourceCodeManager, request):
Expand Down Expand Up @@ -226,8 +240,20 @@ def test_commit_and_tag_from_below_scm_root(repo: str, scm_command: str, scm_cla
@pytest.mark.parametrize(
["repo", "scm_command", "scm_class"],
[
param("git_repo", "git", scm.Git, id="git"),
param("hg_repo", "hg", scm.Mercurial, id="hg"),
param(
"git_repo",
"git",
scm.Git,
id="git",
marks=pytest.mark.skipif(not shutil.which("git"), reason="Git is not available."),
),
param(
"hg_repo",
"hg",
scm.Mercurial,
id="hg",
marks=pytest.mark.skipif(not shutil.which("hg"), reason="Mercurial is not available."),
),
],
)
@pytest.mark.parametrize(
Expand Down

0 comments on commit efab98d

Please sign in to comment.