Commit f83cf537 authored by Jérome Perrin's avatar Jérome Perrin Committed by Gabriel Monnerat

Keep a reference to _module_cache_set in each test request

see 3a92d8b6
parent e26cc4bb
...@@ -37,6 +37,7 @@ from Testing import ZopeTestCase ...@@ -37,6 +37,7 @@ from Testing import ZopeTestCase
from Testing.ZopeTestCase import PortalTestCase, user_name from Testing.ZopeTestCase import PortalTestCase, user_name
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.tests.ProcessingNodeTestCase import ProcessingNodeTestCase from Products.ERP5Type.tests.ProcessingNodeTestCase import ProcessingNodeTestCase
from Products.ERP5Type.Globals import get_request
from Products.ERP5Type.tests.ERP5TypeTestCase import \ from Products.ERP5Type.tests.ERP5TypeTestCase import \
ERP5TypeTestCaseMixin, ERP5TypeTestCase ERP5TypeTestCaseMixin, ERP5TypeTestCase
from glob import glob from glob import glob
...@@ -74,10 +75,18 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin): ...@@ -74,10 +75,18 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
def getPortal(self): def getPortal(self):
"""Returns the portal object, i.e. the "fixture root". """Returns the portal object, i.e. the "fixture root".
Rewrap the portal in an independant request for this test.
""" """
if self.portal is not None: if self.portal is not None:
return self.portal return self.portal
# _module_cache_set is used to keep a reference to the code of modules
# before they get reloaded. As we will use another request we need to
# make sure that we still have a reference to _module_cache_set so that
# it does not get garbage collected.
module_cache_set = getattr(get_request(), '_module_cache_set', None)
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
site = getSite() site = getSite()
# reconstruct the acquistion chain with an independant request. # reconstruct the acquistion chain with an independant request.
...@@ -85,6 +94,9 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin): ...@@ -85,6 +94,9 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
from Testing.ZopeTestCase.utils import makerequest from Testing.ZopeTestCase.utils import makerequest
portal = getattr(makerequest(site.aq_parent), site.getId()) portal = getattr(makerequest(site.aq_parent), site.getId())
if module_cache_set:
portal.REQUEST._module_cache_set = module_cache_set
# Make the various get_request patches return this request. # Make the various get_request patches return this request.
# This is for ERP5TypeTestCase patch # This is for ERP5TypeTestCase patch
from Testing.ZopeTestCase.connections import registry from Testing.ZopeTestCase.connections import registry
......
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