|
7 | 7 | from pytest_mock import MockFixture
|
8 | 8 |
|
9 | 9 | from commitizen import cli
|
10 |
| -from commitizen.exceptions import ExpectedExit, NoCommandFoundError, NotAGitProjectError |
| 10 | +from commitizen.exceptions import ( |
| 11 | + ExpectedExit, NoCommandFoundError, NotAGitProjectError, InvalidCommandArgumentError, NothingToCommitError |
| 12 | +) |
11 | 13 |
|
12 | 14 |
|
13 | 15 | def test_sysexit_no_argv(mocker: MockFixture, capsys):
|
@@ -149,3 +151,19 @@ def test_parse_no_raise_mix_invalid_arg_is_skipped():
|
149 | 151 | input_str = "NO_COMMITIZEN_FOUND,2,nothing,4"
|
150 | 152 | result = cli.parse_no_raise(input_str)
|
151 | 153 | assert result == [1, 2, 4]
|
| 154 | + |
| 155 | + |
| 156 | +def test_unknown_args_raises(mocker: MockFixture): |
| 157 | + testargs = ["cz", "c", "-this_arg_is_not_supported"] |
| 158 | + mocker.patch.object(sys, "argv", testargs) |
| 159 | + with pytest.raises(InvalidCommandArgumentError) as excinfo: |
| 160 | + cli.main() |
| 161 | + assert "Invalid commitizen arguments were found" in str(excinfo.value) |
| 162 | + |
| 163 | + |
| 164 | +def test_unknown_args_before_double_dash_raises(mocker: MockFixture): |
| 165 | + testargs = ["cz", "c", "-this_arg_is_not_supported", "--"] |
| 166 | + mocker.patch.object(sys, "argv", testargs) |
| 167 | + with pytest.raises(InvalidCommandArgumentError) as excinfo: |
| 168 | + cli.main() |
| 169 | + assert "Invalid commitizen arguments were found before -- separator" in str(excinfo.value) |
0 commit comments