Commit d931c6f6 authored by Sebastien Robin's avatar Sebastien Robin

unit test: Enable again calls to setUpOnce when for portal components tests

parent e1ce3bed
...@@ -731,6 +731,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -731,6 +731,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
return sorted([ str(message.getMessage()) return sorted([ str(message.getMessage())
for message in obj.checkConsistency() ]) for message in obj.checkConsistency() ])
def _callSetUpOnce(self):
setup_once = getattr(self, 'setUpOnce', None)
if setup_once is not None and \
not getattr(self.portal, 'set_up_once_called', 0):
self.portal.set_up_once_called = 1
ZopeTestCase._print('Executing setUpOnce ... ')
start = time.time()
setup_once()
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start))
class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
def getPortalName(self): def getPortalName(self):
...@@ -1073,16 +1083,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): ...@@ -1073,16 +1083,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
'Assignor', 'Author', 'Auditor', 'Associate'], []) 'Assignor', 'Author', 'Auditor', 'Associate'], [])
user = uf.getUserById('ERP5TypeTestCase').__of__(uf) user = uf.getUserById('ERP5TypeTestCase').__of__(uf)
setup_once = getattr(self, 'setUpOnce', None) self._callSetUpOnce()
if setup_once is not None and \
not getattr(portal, 'set_up_once_called', 0):
portal.set_up_once_called = 1
if not quiet:
ZopeTestCase._print('Executing setUpOnce ... ')
start = time.time()
setup_once()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start))
# Enable reindexing # Enable reindexing
# Do hot reindexing # Does not work # Do hot reindexing # Does not work
......
...@@ -304,10 +304,16 @@ class ERP5TypeTestLoader(unittest.TestLoader): ...@@ -304,10 +304,16 @@ class ERP5TypeTestLoader(unittest.TestLoader):
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase
class ComponentTestCase(ERP5TypeLiveTestCase):
def setUp(self):
super(ComponentTestCase, self).setUp()
self._callSetUpOnce()
# Bootstrap has been done in loadTestsFromNames, so the test can now # Bootstrap has been done in loadTestsFromNames, so the test can now
# be loaded like any Live Test on a real instance # be loaded like any Live Test on a real instance
if ERP5TypeLiveTestCase not in ERP5TypeTestCase.__bases__: if ComponentTestCase not in ERP5TypeTestCase.__bases__:
ERP5TypeTestCase.__bases__ = ERP5TypeLiveTestCase, ERP5TypeTestCase.__bases__ = ComponentTestCase,
# TestLoader() does not perform any import so import the Module manually # TestLoader() does not perform any import so import the Module manually
module = __import__('erp5.component.test', module = __import__('erp5.component.test',
......
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