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)):
# Drop remaining activities if some of them failed.
# However, we should not do more activity cleaning, because properly
# written unit tests should not leave unprocessed activity messages.
# And the user may want to analyse the result of a failed unit test,
# so we do nothing in persistent mode (--save).
try: try:
portal_activities = self.portal.portal_activities portal_activities = self.portal.portal_activities
# Drop remaining activities. except AttributeError:
pass
else:
for m in self.portal.portal_activities.getMessageList():
if m.processing_node < -1:
count = portal_activities.countMessage() count = portal_activities.countMessage()
portal_activities.manageClearActivities(keep=False) portal_activities.manageClearActivities(keep=False)
if count:
LOG('Products.ERP5Type.tests.ERP5TypeTestCase.beforeClose', DEBUG,
'dropped %d left-over activity messages' % (count,))
transaction.commit() transaction.commit()
except AttributeError: ZopeTestCase._print('\ndropped %d left-over activity messages'
pass % 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