summaryrefslogtreecommitdiff
path: root/pytest.py
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-07-29 11:45:55 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-07-29 11:45:55 +0200
commit71f80b37c405e672f25b25beec42c09f7d2bd13e (patch)
tree79a9f152de2a71bf02fea3cf48a370a93b9705d8 /pytest.py
parent96e6c8e68fdfe095287a97a327cbec65b847fe26 (diff)
downloadlogilab-common-71f80b37c405e672f25b25beec42c09f7d2bd13e.tar.gz
[pytest] fix error code handling
Diffstat (limited to 'pytest.py')
-rw-r--r--pytest.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/pytest.py b/pytest.py
index 38b68fe..db43bb8 100644
--- a/pytest.py
+++ b/pytest.py
@@ -332,14 +332,23 @@ class PyTester(object):
self.cvg = cvg
self.options = options
self.firstwrite = True
+ self._errcode = None
def show_report(self):
"""prints the report and returns appropriate exitcode"""
# everything has been ran, print report
print "*" * 79
print self.report
+
+ def get_errcode(self):
+ # errcode set explicity
+ if self._errcode is not None:
+ return self._errcode
return self.report.failures + self.report.errors
+ def set_errcode(self, errcode):
+ self._errcode = errcode
+ errcode = property(get_errcode, set_errcode)
def testall(self, exitfirst=False):
"""walks trhough current working directory, finds something
@@ -417,8 +426,11 @@ succeeded test file :", osp.join(os.getcwd(),testlib.FILE_RESTART)
tstart, cstart = time(), clock()
try:
testprog = testlib.unittest_main(modname, batchmode=batchmode, cvg=self.cvg,
- options=self.options, outstream=outstream)
- except (KeyboardInterrupt, SystemExit):
+ options=self.options, outstream=sys.stderr)
+ except KeyboardInterrupt:
+ raise
+ except SystemExit, exc:
+ self.errcode = exc.code
raise
except testlib.TestSkipped:
print "Module skipped:", filename
@@ -722,7 +734,7 @@ def run():
import traceback
traceback.print_exc()
finally:
- errcode = tester.show_report()
+ tester.show_report()
if covermode:
cvg.stop()
cvg.save()
@@ -735,4 +747,4 @@ def run():
morfdir
cvg.annotate([morfdir])
cvg.report([morfdir], False)
- sys.exit(errcode)
+ sys.exit(tester.errcode)