Skip to content

Commit 2c323c6

Browse files
committed
test(changelog): code coverage improvements
1 parent e93d45d commit 2c323c6

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

commitizen/commands/changelog.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
from commitizen.git import GitTag
1717

1818

19-
def similar(a, b):
20-
return SequenceMatcher(None, a, b).ratio()
21-
22-
2319
class Changelog:
2420
"""Generate a changelog based on the commit history."""
2521

tests/commands/test_changelog_command.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
365365
cli.main()
366366

367367

368+
def test_changelog_incremental_with_revision(mocker):
369+
"""combining incremental with a revision doesn't make sense"""
370+
testargs = ["cz", "changelog", "--incremental", "0.2.0"]
371+
mocker.patch.object(sys, "argv", testargs)
372+
373+
with pytest.raises(NotAllowed):
374+
cli.main()
375+
376+
368377
def test_changelog_with_different_tag_name_and_changelog_content(
369378
mocker, tmp_commitizen_project
370379
):
@@ -895,3 +904,15 @@ def test_invalid_subject_is_skipped(mocker, capsys):
895904
out, _ = capsys.readouterr()
896905

897906
assert out == ("## Unreleased\n\n### Feat\n\n- a new world\n\n")
907+
908+
909+
@pytest.mark.usefixtures("tmp_commitizen_project")
910+
def test_empty_commit_list(mocker):
911+
create_file_and_commit("feat: a new world")
912+
913+
# test changelog properly handles when no commits are found for the revision
914+
mocker.patch("commitizen.git.get_commits", return_value=[])
915+
testargs = ["cz", "changelog"]
916+
mocker.patch.object(sys, "argv", testargs)
917+
with pytest.raises(NoCommitsFoundError):
918+
cli.main()

0 commit comments

Comments
 (0)