Merge pull request #5028 from blueyed/fix-wrap_session-exit-code

wrap_session: restore old behavior for initstate=1
This commit is contained in:
Daniel Hahler
2019-04-04 00:39:38 +02:00
committed by GitHub
3 changed files with 23 additions and 3 deletions

View File

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