Commit 3db20ae6 authored by Jérome Perrin's avatar Jérome Perrin

squash! zope4py2: fix usage of _Z2HOST

_Z2HOST / _Z2PORT no longer exist in Zope4, something was added in
component/egg-patch/Zope/0001-OFS-XMLExportImport.patch in SlapOS
software release, but we never had a strong need to patch there, we
were doing this so that Testing.ZopeTestCase.utils.makerequest creates
a REQUEST to this host:port, but now that Zope's startZServer no longer,
the REQUEST created by Testing.ZopeTestCase.base.app is always to
nohost:80, so we need to rewrap the app in request to our host:port.
parent 14fb95a2
...@@ -57,6 +57,7 @@ getRequest.__code__ = (lambda: get_request()).__code__ ...@@ -57,6 +57,7 @@ getRequest.__code__ = (lambda: get_request()).__code__
from zope.site.hooks import setSite from zope.site.hooks import setSite
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Testing.makerequest import makerequest
from Testing.ZopeTestCase import PortalTestCase, user_name from Testing.ZopeTestCase import PortalTestCase, user_name
from Products.ERP5Type.Core.Workflow import ValidationFailed from Products.ERP5Type.Core.Workflow import ValidationFailed
from Products.PythonScripts.PythonScript import PythonScript from Products.PythonScripts.PythonScript import PythonScript
...@@ -1032,9 +1033,21 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): ...@@ -1032,9 +1033,21 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
def _app(self): def _app(self):
'''Opens a ZODB connection and returns the app object. '''Opens a ZODB connection and returns the app object.
We override it to patch HTTP_ACCEPT_CHARSET into REQUEST to get the zpt We override it so that the request knows about the server we started and
unicode conflict resolver to work properly''' has HTTP_ACCEPT_CHARSET set, to get the zpt unicode conflict resolver to
work properly.
'''
app = PortalTestCase._app(self) app = PortalTestCase._app(self)
from Products.ERP5Type.tests.ProcessingNodeTestCase import _server_addr
if _server_addr:
app.REQUEST.close()
host, port = _server_addr
app = makerequest(
aq_base(app),
environ={
'SERVER_NAME': host,
'SERVER_PORT': port,
})
app.REQUEST['HTTP_ACCEPT_CHARSET'] = 'utf-8' app.REQUEST['HTTP_ACCEPT_CHARSET'] = 'utf-8'
return app return app
......
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