Set test session exitstatus value from Exit excetion return code

This commit is contained in:
Jose Carlos Menezes 2018-10-14 16:39:43 -03:00
parent 46d6a3fc27
commit 836c9f82f1
1 changed files with 4 additions and 2 deletions

View File

@ -185,10 +185,12 @@ def wrap_session(config, doit):
session.exitstatus = EXIT_TESTSFAILED
except KeyboardInterrupt:
excinfo = _pytest._code.ExceptionInfo()
if initstate < 2 and isinstance(excinfo.value, exit.Exception):
exitstatus = EXIT_INTERRUPTED
if initstate <= 2 and isinstance(excinfo.value, exit.Exception):
sys.stderr.write("{}: {}\n".format(excinfo.typename, excinfo.value.msg))
exitstatus = excinfo.value.returncode
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
session.exitstatus = EXIT_INTERRUPTED
session.exitstatus = exitstatus
except: # noqa
excinfo = _pytest._code.ExceptionInfo()
config.notify_exception(excinfo, config.option)