File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 44import pytest
55
66from commitizen import cmd , commands , defaults
7+ from commitizen .cz .exceptions import CzException
78
89config = {"name" : defaults .name }
910
@@ -92,6 +93,24 @@ def test_commit_when_nothing_to_commit(mocker):
9293 assert err .value .code == commands .commit .NOTHING_TO_COMMIT
9394
9495
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+
95114def test_example ():
96115 with mock .patch ("commitizen.out.write" ) as write_mock :
97116 commands .Example (config )()
You can’t perform that action at this time.
0 commit comments