Commit b6a363d7 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add a workaround for the overwriting problem of the instance home in Testing/__init__.py.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@614 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 523df4ca
......@@ -56,6 +56,10 @@ from AccessControl.User import User
from Acquisition import aq_base
import time
import md5
import traceback
import sys
import os
from cStringIO import StringIO
from Products.ERP5.ERP5Site import ERP5Site
......@@ -85,6 +89,18 @@ class ERP5TypeTestCase(PortalTestCase):
'''Sets up the fixture. Do not override,
use the hooks instead.
'''
# This is a workaround for the overwriting problem in Testing/__init__.py in Zope.
# So this overwrites them again to revert the changes made by Testing.
try:
import App.config
except ImportError:
os.environ['INSTANCE_HOME'] = INSTANCE_HOME = os.environ['COPY_OF_INSTANCE_HOME']
os.environ['SOFTWARE_HOME'] = SOFTWARE_HOME = os.environ['COPY_OF_SOFTWARE_HOME']
else:
cfg = App.config.getConfiguration()
cfg.instancehome = os.environ['COPY_OF_INSTANCE_HOME']
App.config.setConfiguration(cfg)
setupERP5Site(business_template_list = self.getBusinessTemplateList(),
portal_name = self.getPortalName())
PortalTestCase.setUp(self)
......@@ -117,9 +133,11 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name,
Creates an ERP5 site.
business_template_list must be specified correctly (e.g. '("erp5_common", )').
'''
try:
if app is None:
app = ZopeTestCase.app()
if not hasattr(aq_base(app), portal_name):
try:
_start = time.time()
# Add user and log in
if not quiet: ZopeTestCase._print('\nAdding ERP5TypeTestCase user ... \n')
......@@ -142,9 +160,15 @@ def setupERP5Site(business_template_list=(), app=None, portal_name=portal_name,
# Log out
if not quiet: ZopeTestCase._print('Logout ... \n')
noSecurityManager()
get_transaction().commit()
if not quiet: ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
finally:
get_transaction().commit()
ZopeTestCase.close(app)
except:
f = StringIO()
traceback.print_exc(file=f)
ZopeTestCase._print(f.getvalue())
f.close()
def optimize():
......
export INSTANCE_HOME=/home/$USER/zope
export SOFTWARE_HOME=/usr/lib/zope/lib/python/
export COPY_OF_INSTANCE_HOME=$INSTANCE_HOME
export COPY_OF_SOFTWARE_HOME=$SOFTWARE_HOME
dir="`dirname $0`"
if test -n "$dir"; then
......
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