File tree 1 file changed +19
-0
lines changed 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
from commitizen import cmd , commands , defaults
7
+ from commitizen .cz .exceptions import CzException
7
8
8
9
config = {"name" : defaults .name }
9
10
@@ -92,6 +93,24 @@ def test_commit_when_nothing_to_commit(mocker):
92
93
assert err .value .code == commands .commit .NOTHING_TO_COMMIT
93
94
94
95
96
+ def test_commit_when_customized_expected_raised (mocker , capsys ):
97
+ _err = ValueError ()
98
+ _err .__context__ = CzException ("This is the root custom err" )
99
+
100
+ prompt_mock = mocker .patch ("questionary.prompt" )
101
+ prompt_mock .side_effect = _err
102
+
103
+ with pytest .raises (SystemExit ) as err :
104
+ commit_cmd = commands .Commit (config , {})
105
+ commit_cmd ()
106
+
107
+ assert err .value .code == commands .commit .CUSTOM_ERROR
108
+
109
+ # Assert only the content in the formatted text
110
+ captured = capsys .readouterr ()
111
+ assert "This is the root custom err" in captured .err
112
+
113
+
95
114
def test_example ():
96
115
with mock .patch ("commitizen.out.write" ) as write_mock :
97
116
commands .Example (config )()
You can’t perform that action at this time.
0 commit comments