Commit 7dcc6c30 authored by Julien Muchembled's avatar Julien Muchembled

Exit status for an interrupted test should not be 0

Also display traceback of interrupt.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35435 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0133943
...@@ -91,6 +91,12 @@ def expectedFailure(func): ...@@ -91,6 +91,12 @@ def expectedFailure(func):
wrapper.__doc__ = func.__doc__ wrapper.__doc__ = func.__doc__
return wrapper return wrapper
try:
BaseException
except NameError:
# BACK: python < 2.5
BaseException = Exception
class TestCase(unittest.TestCase): class TestCase(unittest.TestCase):
"""We redefine here the run() method, and add a skipTest() method. """We redefine here the run() method, and add a skipTest() method.
...@@ -136,10 +142,10 @@ class TestCase(unittest.TestCase): ...@@ -136,10 +142,10 @@ class TestCase(unittest.TestCase):
result.addSkip(self, str(e)) result.addSkip(self, str(e))
except SetupSiteError, e: except SetupSiteError, e:
result.errors.append(None) result.errors.append(None)
except (KeyboardInterrupt, SystemExit): # BACK: Not needed for except BaseException, e:
raise # Python >= 2.5
except Exception:
result.addError(self, sys.exc_info()) result.addError(self, sys.exc_info())
if isinstance(e, (KeyboardInterrupt, SystemExit)):
raise
else: else:
try: try:
testMethod() testMethod()
...@@ -151,19 +157,19 @@ class TestCase(unittest.TestCase): ...@@ -151,19 +157,19 @@ class TestCase(unittest.TestCase):
result.addUnexpectedSuccess(self) result.addUnexpectedSuccess(self)
except SkipTest, e: except SkipTest, e:
result.addSkip(self, str(e)) result.addSkip(self, str(e))
except (KeyboardInterrupt, SystemExit): # BACK: Not needed for except BaseException, e:
raise # Python >= 2.5
except Exception:
result.addError(self, sys.exc_info()) result.addError(self, sys.exc_info())
if isinstance(e, (KeyboardInterrupt, SystemExit)):
raise
else: else:
success = True success = True
try: try:
self.tearDown() self.tearDown()
except (KeyboardInterrupt, SystemExit): # BACK: Not needed for except BaseException, e:
raise # Python >= 2.5
except Exception:
result.addError(self, sys.exc_info()) result.addError(self, sys.exc_info())
if isinstance(e, (KeyboardInterrupt, SystemExit)):
raise
success = False success = False
# BACK: Not needed for Python < 2.7 # BACK: Not needed for Python < 2.7
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment