Commit d78f98f7 authored by Jérome Perrin's avatar Jérome Perrin

LiveTest: set SERVER_URL in the test request so that tests run with same URL as the host

(cherry picked from commit 8fab4d97)
parent d452124f
......@@ -295,6 +295,7 @@ class Test(ERP5TypeTestCase):
debug = int(debug) and True or False
run_only = self._getCommaSeparatedParameterList(run_only)
verbosity = verbose and 2 or 1
request_server_url = self.REQUEST.get('SERVER_URL')
try:
live_test_running = True
......@@ -304,6 +305,7 @@ class Test(ERP5TypeTestCase):
run_only=run_only,
debug=debug,
stream=global_stream,
request_server_url=request_server_url,
verbosity=verbosity)
except ImportError:
import traceback
......
......@@ -51,6 +51,7 @@ from Products.ERP5Type.tests import ProcessingNodeTestCase as\
ProcessingNodeTestCaseModule
ProcessingNodeTestCaseModule.patchActivityTool = lambda: None
_request_server_url = None
class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
"""ERP5TypeLiveTestCase is the default class for *all* tests
......@@ -109,6 +110,11 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
with patches._requests_lock:
patches._requests[thread.get_ident()] = request
# Make live tests run under the same server URL than the host instance.
if _request_server_url:
request['SERVER_URL'] = _request_server_url
request._resetURLS()
self.portal = portal
return portal
......@@ -186,7 +192,7 @@ class ERP5TypeLiveTestLoader(ERP5TypeTestLoader):
return super(ERP5TypeLiveTestLoader, self).loadTestsFromName(name,
module)
def runLiveTest(test_list, verbosity=1, stream=None, **kw):
def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **kw):
from Products.ERP5Type.tests.runUnitTest import DebugTestResult
from StringIO import StringIO
# Add path of the TestTemplateItem folder of the instance
......@@ -199,6 +205,9 @@ def runLiveTest(test_list, verbosity=1, stream=None, **kw):
product_test_list.extend(glob(os.path.join(product_path, '*', 'tests')))
current_syspath = set(sys.path)
global _request_server_url
_request_server_url = request_server_url
sys.path.extend(path for path in product_test_list
if path not in current_syspath)
......
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