|
12 | 12 | from commitizen import __file__ as commitizen_init
|
13 | 13 | from commitizen import cli, git
|
14 | 14 | from commitizen.commands.changelog import Changelog
|
| 15 | +from commitizen.config.base_config import BaseConfig |
15 | 16 | from commitizen.cz.base import BaseCommitizen
|
16 | 17 | from commitizen.exceptions import (
|
17 | 18 | DryRunExit,
|
@@ -275,20 +276,24 @@ def test_changelog_incremental_keep_a_changelog_sample(
|
275 | 276 |
|
276 | 277 |
|
277 | 278 | @pytest.mark.usefixtures("tmp_commitizen_project")
|
278 |
| -def test_changelog_hook(mocker: MockFixture, config): |
| 279 | +@pytest.mark.parametrize("dry_run", [True, False]) |
| 280 | +def test_changelog_hook(mocker: MockFixture, config: BaseConfig, dry_run: bool): |
279 | 281 | changelog_hook_mock = mocker.Mock()
|
280 | 282 | changelog_hook_mock.return_value = "cool changelog hook"
|
281 | 283 |
|
282 | 284 | create_file_and_commit("feat: new file")
|
283 | 285 | create_file_and_commit("refactor: is in changelog")
|
284 | 286 | create_file_and_commit("Merge into master")
|
285 | 287 |
|
286 |
| - config.settings["change_type_order"] = ["Refactor", "Feat"] |
| 288 | + config.settings["change_type_order"] = ["Refactor", "Feat"] # type: ignore[typeddict-unknown-key] |
287 | 289 | changelog = Changelog(
|
288 |
| - config, {"unreleased_version": None, "incremental": True, "dry_run": False} |
| 290 | + config, {"unreleased_version": None, "incremental": True, "dry_run": dry_run} |
289 | 291 | )
|
290 | 292 | mocker.patch.object(changelog.cz, "changelog_hook", changelog_hook_mock)
|
291 |
| - changelog() |
| 293 | + try: |
| 294 | + changelog() |
| 295 | + except DryRunExit: |
| 296 | + pass |
292 | 297 | full_changelog = (
|
293 | 298 | "## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n"
|
294 | 299 | )
|
|
0 commit comments