Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c8f058a

Browse files
author
SCrocky
committed
test(cli.py): Added tests for -- argument notation raises
1 parent 75c9f56 commit c8f058a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

‎tests/test_cli.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
from pytest_mock import MockFixture
88

99
from commitizen import cli
10-
from commitizen.exceptions import ExpectedExit, NoCommandFoundError, NotAGitProjectError
10+
from commitizen.exceptions import (
11+
ExpectedExit, NoCommandFoundError, NotAGitProjectError, InvalidCommandArgumentError, NothingToCommitError
12+
)
1113

1214

1315
def test_sysexit_no_argv(mocker: MockFixture, capsys):
@@ -149,3 +151,19 @@ def test_parse_no_raise_mix_invalid_arg_is_skipped():
149151
input_str = "NO_COMMITIZEN_FOUND,2,nothing,4"
150152
result = cli.parse_no_raise(input_str)
151153
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /