diff --git a/product/ERP5Type/tests/ERP5TypeLiveTestCase.py b/product/ERP5Type/tests/ERP5TypeLiveTestCase.py index b87fcb0ddea28c5e9ee9635e648b87e35fcf87f2..7c8ebd926ddf91f69334c98156f1a37c3c92bad6 100644 --- a/product/ERP5Type/tests/ERP5TypeLiveTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeLiveTestCase.py @@ -29,10 +29,14 @@ import unittest import os +from Testing import ZopeTestCase from Testing.ZopeTestCase import PortalTestCase, user_name from Products.ERP5Type.tests.ProcessingNodeTestCase import ProcessingNodeTestCase +from Products.ERP5Type.Globals import get_request import transaction +from zLOG import LOG, DEBUG, INFO + def profile_if_environ(environment_var_name): if int(os.environ.get(environment_var_name, 0)): def decorator(self, method): @@ -143,9 +147,15 @@ class ERP5TypeLiveTestCase(ProcessingNodeTestCase, PortalTestCase): self._setup() self.afterSetUp() except: + self.beforeClear() self._clear() raise + def _app(self): + '''Returns the app object for a test.''' + request = get_request() + return request.PARENTS[-1] + def afterSetUp(self): '''Called after setUp() has completed. This is far and away the most useful hook. @@ -158,6 +168,13 @@ class ERP5TypeLiveTestCase(ProcessingNodeTestCase, PortalTestCase): ''' pass + def beforeClear(self): + '''Called before _clear(). Subclasses should + use it to garbage collect objects which must not remain + in the system + ''' + pass + def logMessage(self, message): """ Shortcut function to log a message