Skip to content

Commit a9e1940

Browse files
committed
Use SystemExit instead of PreCommitSystemExit
1 parent 3f7e715 commit a9e1940

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

pre_commit/error_handler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
from pre_commit.store import Store
1515

1616

17-
# For testing purposes
18-
class PreCommitSystemExit(SystemExit):
19-
pass
20-
21-
2217
def _to_bytes(exc):
2318
try:
2419
return bytes(exc)
@@ -39,7 +34,7 @@ def _log_and_exit(msg, exc, formatted):
3934
with open(os.path.join(store.directory, 'pre-commit.log'), 'wb') as log:
4035
output.write(error_msg, stream=log)
4136
output.write_line(formatted, stream=log)
42-
raise PreCommitSystemExit(1)
37+
raise SystemExit(1)
4338

4439

4540
@contextlib.contextmanager

tests/error_handler_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
7575

7676

7777
def test_log_and_exit(cap_out, mock_out_store_directory):
78-
with pytest.raises(error_handler.PreCommitSystemExit):
78+
with pytest.raises(SystemExit):
7979
error_handler._log_and_exit(
8080
'msg', FatalError('hai'), "I'm a stacktrace",
8181
)
@@ -96,7 +96,7 @@ def test_log_and_exit(cap_out, mock_out_store_directory):
9696

9797

9898
def test_error_handler_non_ascii_exception(mock_out_store_directory):
99-
with pytest.raises(error_handler.PreCommitSystemExit):
99+
with pytest.raises(SystemExit):
100100
with error_handler.error_handler():
101101
raise ValueError('☃')
102102

tests/main_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pytest
88

99
from pre_commit import main
10-
from pre_commit.error_handler import PreCommitSystemExit
1110
from pre_commit.util import cwd
1211
from testing.auto_namedtuple import auto_namedtuple
1312

@@ -120,7 +119,7 @@ def test_expected_fatal_error_no_git_repo(
120119
tempdir_factory, cap_out, mock_out_store_directory,
121120
):
122121
with cwd(tempdir_factory.get()):
123-
with pytest.raises(PreCommitSystemExit):
122+
with pytest.raises(SystemExit):
124123
main.main([])
125124
assert cap_out.get() == (
126125
'An error has occurred: FatalError: git failed. '

0 commit comments

Comments
 (0)