unify logic for error exit on test failures

This commit is contained in:
Ronny Pfannschmidt 2013-02-14 12:13:04 +01:00
parent 857c99d354
commit ca8b3c2307
1 changed files with 6 additions and 4 deletions

View File

@ -93,12 +93,14 @@ def wrap_session(config, doit):
session.exitstatus = EXIT_INTERNALERROR session.exitstatus = EXIT_INTERNALERROR
if excinfo.errisinstance(SystemExit): if excinfo.errisinstance(SystemExit):
sys.stderr.write("mainloop: caught Spurious SystemExit!\n") sys.stderr.write("mainloop: caught Spurious SystemExit!\n")
else:
if session._testsfailed:
session.exitstatus = EXIT_TESTSFAILED
finally: finally:
if initstate >= 2: if initstate >= 2:
config.hook.pytest_sessionfinish(session=session, config.hook.pytest_sessionfinish(
exitstatus=session.exitstatus or (session._testsfailed and 1)) session=session,
if not session.exitstatus and session._testsfailed: exitstatus=session.exitstatus)
session.exitstatus = EXIT_TESTSFAILED
if initstate >= 1: if initstate >= 1:
config.pluginmanager.do_unconfigure(config) config.pluginmanager.do_unconfigure(config)
return session.exitstatus return session.exitstatus