|
8 | 8 | import pytest |
9 | 9 | from pytest_mock import MockFixture |
10 | 10 |
|
11 | | -from commitizen import cmd, exceptions, git |
| 11 | +from commitizen import cmd, git |
| 12 | +from commitizen.exceptions import GitCommandError |
12 | 13 | from tests.utils import ( |
13 | 14 | FakeCommand, |
14 | 15 | create_branch, |
@@ -110,10 +111,13 @@ def test_git_message_with_empty_body(): |
110 | 111 |
|
111 | 112 | @pytest.mark.usefixtures("tmp_commitizen_project") |
112 | 113 | def test_get_log_as_str_list_empty(): |
113 | | - """ensure an exception or empty list in an empty project""" |
| 114 | + """ |
| 115 | + Ensure an exception is raised or empty list in an empty project. |
| 116 | + The behavior is different depending on the version of git. |
| 117 | + """ |
114 | 118 | try: |
115 | 119 | gitlog = git._get_log_as_str_list(start=None, end="HEAD", args="") |
116 | | - except exceptions.GitCommandError: |
| 120 | + except GitCommandError: |
117 | 121 | return |
118 | 122 | assert len(gitlog) == 0, "list should be empty if no assert" |
119 | 123 |
|
@@ -409,7 +413,7 @@ def test_get_filenames_in_commit_error(mocker: MockFixture): |
409 | 413 | "commitizen.cmd.run", |
410 | 414 | return_value=FakeCommand(out="", err="fatal: bad object HEAD", return_code=1), |
411 | 415 | ) |
412 | | - with pytest.raises(exceptions.GitCommandError) as excinfo: |
| 416 | + with pytest.raises(GitCommandError) as excinfo: |
413 | 417 | git.get_filenames_in_commit() |
414 | 418 | assert str(excinfo.value) == "fatal: bad object HEAD" |
415 | 419 |
|
@@ -497,5 +501,5 @@ def test_get_default_branch_error(mocker: MockFixture): |
497 | 501 | return_code=1, |
498 | 502 | ), |
499 | 503 | ) |
500 | | - with pytest.raises(exceptions.GitCommandError): |
| 504 | + with pytest.raises(GitCommandError): |
501 | 505 | git.get_default_branch() |
0 commit comments