From ca8b3c2307c8e9a8cdb8db3876bf1db2fe253246 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 14 Feb 2013 12:13:04 +0100 Subject: [PATCH] unify logic for error exit on test failures --- _pytest/main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/_pytest/main.py b/_pytest/main.py index 6063c230f..95b2359bc 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -93,12 +93,14 @@ def wrap_session(config, doit): session.exitstatus = EXIT_INTERNALERROR if excinfo.errisinstance(SystemExit): sys.stderr.write("mainloop: caught Spurious SystemExit!\n") + else: + if session._testsfailed: + session.exitstatus = EXIT_TESTSFAILED finally: if initstate >= 2: - config.hook.pytest_sessionfinish(session=session, - exitstatus=session.exitstatus or (session._testsfailed and 1)) - if not session.exitstatus and session._testsfailed: - session.exitstatus = EXIT_TESTSFAILED + config.hook.pytest_sessionfinish( + session=session, + exitstatus=session.exitstatus) if initstate >= 1: config.pluginmanager.do_unconfigure(config) return session.exitstatus