|
4 | 4 |
|
5 | 5 | from commitizen import cli
|
6 | 6 | from commitizen.__version__ import __version__
|
7 |
| -from commitizen.exceptions import ExpectedExit, NoCommandFoundError |
| 7 | +from commitizen.exceptions import ExpectedExit, NoCommandFoundError, NotAGitProjectError |
8 | 8 |
|
9 | 9 |
|
10 | 10 | def test_sysexit_no_argv(mocker, capsys):
|
@@ -75,3 +75,22 @@ def test_arg_debug(mocker):
|
75 | 75 | mocker.patch.object(sys, "argv", testargs)
|
76 | 76 | cli.main()
|
77 | 77 | assert sys.excepthook.keywords.get("debug") is True
|
| 78 | + |
| 79 | + |
| 80 | +def test_commitizen_excepthook(capsys): |
| 81 | + with pytest.raises(SystemExit) as excinfo: |
| 82 | + cli.commitizen_excepthook(NotAGitProjectError, NotAGitProjectError(), "") |
| 83 | + |
| 84 | + assert excinfo.type == SystemExit |
| 85 | + assert excinfo.value.code == NotAGitProjectError.exit_code |
| 86 | + |
| 87 | + |
| 88 | +def test_commitizen_debug_excepthook(capsys): |
| 89 | + with pytest.raises(SystemExit) as excinfo: |
| 90 | + cli.commitizen_excepthook( |
| 91 | + NotAGitProjectError, NotAGitProjectError(), "", debug=True, |
| 92 | + ) |
| 93 | + |
| 94 | + assert excinfo.type == SystemExit |
| 95 | + assert excinfo.value.code == NotAGitProjectError.exit_code |
| 96 | + assert "NotAGitProjectError" in str(excinfo.traceback[0]) |
0 commit comments