File tree 3 files changed +6
-5
lines changed
3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,8 @@ def wrap_session(config, doit):
205
205
raise
206
206
except Failed :
207
207
session .exitstatus = EXIT_TESTSFAILED
208
- except KeyboardInterrupt :
208
+ # except KeyboardInterrupt:
209
+ except (KeyboardInterrupt , exit .Exception ):
209
210
excinfo = _pytest ._code .ExceptionInfo .from_current ()
210
211
exitstatus = EXIT_INTERRUPTED
211
212
if initstate <= 2 and isinstance (excinfo .value , exit .Exception ):
Original file line number Diff line number Diff line change @@ -49,21 +49,21 @@ class Failed(OutcomeException):
49
49
__module__ = "builtins"
50
50
51
51
52
- class Exit (KeyboardInterrupt ):
52
+ class Exit (SystemExit ):
53
53
""" raised for immediate program exits (no tracebacks/summaries)"""
54
54
55
55
def __init__ (self , msg = "unknown reason" , returncode = None ):
56
56
self .msg = msg
57
57
self .returncode = returncode
58
- KeyboardInterrupt .__init__ (self , msg )
58
+ SystemExit .__init__ (self , msg )
59
59
60
60
61
61
# exposed helper methods
62
62
63
63
64
64
def exit (msg , returncode = None ):
65
65
"""
66
- Exit testing process as if KeyboardInterrupt was triggered.
66
+ Exit testing process as if SystemExit was triggered.
67
67
68
68
:param str msg: message to display upon exit.
69
69
:param int returncode: return code to be used when exiting pytest.
Original file line number Diff line number Diff line change @@ -553,7 +553,7 @@ def test_outcomeexception_passes_except_Exception():
553
553
def test_pytest_exit ():
554
554
with pytest .raises (pytest .exit .Exception ) as excinfo :
555
555
pytest .exit ("hello" )
556
- assert excinfo .errisinstance (KeyboardInterrupt )
556
+ assert excinfo .errisinstance (pytest . exit . Exception )
557
557
558
558
559
559
def test_pytest_fail ():
You can’t perform that action at this time.
0 commit comments