@@ -33,6 +33,7 @@ def test_error_handler_fatal_error(mocked_log_and_exit):
3333
3434 mocked_log_and_exit .assert_called_once_with (
3535 'An error has occurred' ,
36+ 1 ,
3637 exc ,
3738 # Tested below
3839 mock .ANY ,
@@ -47,7 +48,7 @@ def test_error_handler_fatal_error(mocked_log_and_exit):
4748 r' raise exc\n'
4849 r'(pre_commit\.errors\.)?FatalError: just a test\n' ,
4950 )
50- pattern .assert_matches (mocked_log_and_exit .call_args [0 ][2 ])
51+ pattern .assert_matches (mocked_log_and_exit .call_args [0 ][3 ])
5152
5253
5354def test_error_handler_uncaught_error (mocked_log_and_exit ):
@@ -57,6 +58,7 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
5758
5859 mocked_log_and_exit .assert_called_once_with (
5960 'An unexpected error has occurred' ,
61+ 3 ,
6062 exc ,
6163 # Tested below
6264 mock .ANY ,
@@ -70,7 +72,7 @@ def test_error_handler_uncaught_error(mocked_log_and_exit):
7072 r' raise exc\n'
7173 r'ValueError: another test\n' ,
7274 )
73- pattern .assert_matches (mocked_log_and_exit .call_args [0 ][2 ])
75+ pattern .assert_matches (mocked_log_and_exit .call_args [0 ][3 ])
7476
7577
7678def test_error_handler_keyboardinterrupt (mocked_log_and_exit ):
@@ -80,6 +82,7 @@ def test_error_handler_keyboardinterrupt(mocked_log_and_exit):
8082
8183 mocked_log_and_exit .assert_called_once_with (
8284 'Interrupted (^C)' ,
85+ 130 ,
8386 exc ,
8487 # Tested below
8588 mock .ANY ,
@@ -93,7 +96,7 @@ def test_error_handler_keyboardinterrupt(mocked_log_and_exit):
9396 r' raise exc\n'
9497 r'KeyboardInterrupt\n' ,
9598 )
96- pattern .assert_matches (mocked_log_and_exit .call_args [0 ][2 ])
99+ pattern .assert_matches (mocked_log_and_exit .call_args [0 ][3 ])
97100
98101
99102def test_log_and_exit (cap_out , mock_store_dir ):
@@ -103,8 +106,9 @@ def test_log_and_exit(cap_out, mock_store_dir):
103106 'pre_commit.errors.FatalError: hai\n '
104107 )
105108
106- with pytest .raises (SystemExit ):
107- error_handler ._log_and_exit ('msg' , FatalError ('hai' ), tb )
109+ with pytest .raises (SystemExit ) as excinfo :
110+ error_handler ._log_and_exit ('msg' , 1 , FatalError ('hai' ), tb )
111+ assert excinfo .value .code == 1
108112
109113 printed = cap_out .get ()
110114 log_file = os .path .join (mock_store_dir , 'pre-commit.log' )
@@ -170,7 +174,7 @@ def test_error_handler_no_tty(tempdir_factory):
170174 'from pre_commit.error_handler import error_handler\n '
171175 'with error_handler():\n '
172176 ' raise ValueError("\\ u2603")\n ' ,
173- retcode = 1 ,
177+ retcode = 3 ,
174178 tempdir_factory = tempdir_factory ,
175179 pre_commit_home = pre_commit_home ,
176180 )
0 commit comments