Commit 5fd3e7a5 authored by Julien Muchembled's avatar Julien Muchembled

Unit tests: by default, drop remaining activities if some of them failed

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38137 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0b817d25
...@@ -999,19 +999,26 @@ class ERP5TypeTestCase(ProcessingNodeTestCase, PortalTestCase): ...@@ -999,19 +999,26 @@ class ERP5TypeTestCase(ProcessingNodeTestCase, PortalTestCase):
PortalTestCase.tearDown(self) PortalTestCase.tearDown(self)
setSite() # undo site configuration from self.getPortal() setSite() # undo site configuration from self.getPortal()
def beforeClose(self): def beforeTearDown(self):
PortalTestCase.beforeClose(self) if not int(os.environ.get('erp5_save_data_fs', 0)):
try: # Drop remaining activities if some of them failed.
portal_activities = self.portal.portal_activities # However, we should not do more activity cleaning, because properly
# Drop remaining activities. # written unit tests should not leave unprocessed activity messages.
count = portal_activities.countMessage() # And the user may want to analyse the result of a failed unit test,
portal_activities.manageClearActivities(keep=False) # so we do nothing in persistent mode (--save).
if count: try:
LOG('Products.ERP5Type.tests.ERP5TypeTestCase.beforeClose', DEBUG, portal_activities = self.portal.portal_activities
'dropped %d left-over activity messages' % (count,)) except AttributeError:
transaction.commit() pass
except AttributeError: else:
pass for m in self.portal.portal_activities.getMessageList():
if m.processing_node < -1:
count = portal_activities.countMessage()
portal_activities.manageClearActivities(keep=False)
transaction.commit()
ZopeTestCase._print('\ndropped %d left-over activity messages'
% count)
break
def stepPdb(self, sequence=None, sequence_list=None): def stepPdb(self, sequence=None, sequence_list=None):
"""Invoke debugger""" """Invoke debugger"""
......
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