File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,8 @@ def wrap_session(config, doit):
90
90
session .exitstatus = doit (config , session ) or 0
91
91
except pytest .UsageError :
92
92
raise
93
- except KeyboardInterrupt :
93
+ except KeyboardInterrupt as e :
94
+ sys .stderr .write ('{0}: {1}\n ' .format (type (e ).__name__ , e .msg ))
94
95
excinfo = _pytest ._code .ExceptionInfo ()
95
96
config .hook .pytest_keyboard_interrupt (excinfo = excinfo )
96
97
session .exitstatus = EXIT_INTERRUPTED
Original file line number Diff line number Diff line change @@ -457,6 +457,18 @@ def test_pytest_fail():
457
457
s = excinfo .exconly (tryshort = True )
458
458
assert s .startswith ("Failed" )
459
459
460
+ def test_pytest_exit_msg (testdir ):
461
+ testdir .makeconftest ("""
462
+ import pytest
463
+
464
+ def pytest_configure(config):
465
+ pytest.exit('oh noes')
466
+ """ )
467
+ result = testdir .runpytest ()
468
+ result .stderr .fnmatch_lines ([
469
+ "Exit: oh noes" ,
470
+ ])
471
+
460
472
def test_pytest_fail_notrace (testdir ):
461
473
testdir .makepyfile ("""
462
474
import pytest
You can’t perform that action at this time.
0 commit comments