Skip to content

Commit 40a3c78

Browse files
committed
test: brought back the pre-commit tests along with prek
1 parent a7135d9 commit 40a3c78

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ test = [
107107
"pytest-freezer>=0.4.6",
108108
"pytest-xdist>=3.1.0",
109109
"pytest-gitconfig>=0.9.0",
110+
"pre-commit>=4.5.1",
110111
]
111112

112113
linters = [

tests/test_bump_create_commit_message.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_create_tag(test_input, expected):
2424
assert new_tag == expected
2525

2626

27+
@pytest.mark.parametrize("hook_runner", ("pre-commit", "prek"))
2728
@pytest.mark.parametrize(
2829
"retry",
2930
(
@@ -38,7 +39,7 @@ def test_create_tag(test_input, expected):
3839
),
3940
)
4041
@pytest.mark.usefixtures("tmp_commitizen_project")
41-
def test_bump_pre_commit_changelog(util: UtilFixture, retry):
42+
def test_bump_pre_commit_changelog(util: UtilFixture, retry, hook_runner):
4243
util.freezer.move_to("2022-04-01")
4344
bump_args = ["bump", "--changelog", "--yes"]
4445
if retry:
@@ -69,7 +70,7 @@ def test_bump_pre_commit_changelog(util: UtilFixture, retry):
6970
)
7071
cmd.run("git add -A")
7172
cmd.run('git commit -m "fix: _test"')
72-
cmd.run("prek install")
73+
cmd.run(f"{hook_runner} install")
7374
util.run_cli(*bump_args)
7475
# Pre-commit fixed last line adding extra indent and "\" char
7576
assert Path("CHANGELOG.md").read_text() == dedent(
@@ -83,9 +84,10 @@ def test_bump_pre_commit_changelog(util: UtilFixture, retry):
8384
)
8485

8586

87+
@pytest.mark.parametrize("hook_runner", ("pre-commit", "prek"))
8688
@pytest.mark.parametrize("retry", (True, False))
8789
@pytest.mark.usefixtures("tmp_commitizen_project")
88-
def test_bump_pre_commit_changelog_fails_always(util: UtilFixture, retry):
90+
def test_bump_pre_commit_changelog_fails_always(util: UtilFixture, retry, hook_runner):
8991
util.freezer.move_to("2022-04-01")
9092
bump_args = ["bump", "--changelog", "--yes"]
9193
if retry:
@@ -106,7 +108,7 @@ def test_bump_pre_commit_changelog_fails_always(util: UtilFixture, retry):
106108
)
107109
cmd.run("git add -A")
108110
cmd.run('git commit -m "feat: forbid changelogs"')
109-
cmd.run("prek install")
111+
cmd.run(f"{hook_runner} install")
110112
with pytest.raises(exceptions.BumpCommitFailedError):
111113
util.run_cli(*bump_args)
112114

uv.lock

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)