Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e702f79

Browse files
SCrockyLee-W
SCrocky
authored andcommitted
test(cli.py): Added tests for -- argument notation raises
1 parent 069fbb7 commit e702f79

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/test_cli.py

+19-1
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)