Fix #1210 display msg for early calls to exit

This commit is contained in:
Tom Viner
2016-07-24 14:13:43 +02:00
parent 655df7f839
commit 42adaf5a61
4 changed files with 24 additions and 1 deletions

View File

@@ -92,6 +92,11 @@ def wrap_session(config, doit):
raise
except KeyboardInterrupt:
excinfo = _pytest._code.ExceptionInfo()
if initstate < 2 and isinstance(
excinfo.value, pytest.exit.Exception):
excinfo = _pytest._code.ExceptionInfo()
sys.stderr.write('{0}: {1}\n'.format(
type(excinfo.value).__name__, excinfo.value.msg))
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
session.exitstatus = EXIT_INTERRUPTED
except: