Commit 6c458b79 authored by Sebastien Robin's avatar Sebastien Robin

prepare methods to allows dynamic display of results

in browser through jquery

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39388 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ba25cf4b
...@@ -37,6 +37,7 @@ from Products.CMFCore.utils import UniqueObject ...@@ -37,6 +37,7 @@ from Products.CMFCore.utils import UniqueObject
import OFS import OFS
import transaction import transaction
from cStringIO import StringIO
from zExceptions import BadRequest from zExceptions import BadRequest
from zExceptions import Unauthorized from zExceptions import Unauthorized
from Acquisition import Implicit from Acquisition import Implicit
...@@ -72,6 +73,8 @@ import Products ...@@ -72,6 +73,8 @@ import Products
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
global_stream = None
""" """
ClassTool allows to create classes from the ZMI using code templates. ClassTool allows to create classes from the ZMI using code templates.
ZMI-created classes can then be edited again. ZMI-created classes can then be edited again.
...@@ -1186,6 +1189,19 @@ def initialize( context ): ...@@ -1186,6 +1189,19 @@ def initialize( context ):
writeLocalConstraint(class_id, text, create=create, writeLocalConstraint(class_id, text, create=create,
instance_home=self._v_instance_home.getPath()) instance_home=self._v_instance_home.getPath())
security.declareProtected(Permissions.ManagePortal, 'runLiveTest')
def readTestOutput(self, position=0):
"""
Return unread part of the test result
"""
result = ''
position = int(position)
global global_stream
if global_stream is not None:
global_stream.seek(position)
result = global_stream.read()
return result
security.declareProtected(Permissions.ManagePortal, 'runLiveTest') security.declareProtected(Permissions.ManagePortal, 'runLiveTest')
def runLiveTest(self, test_list=[], run_only=None, debug=None, def runLiveTest(self, test_list=[], run_only=None, debug=None,
verbose=False): verbose=False):
...@@ -1200,8 +1216,13 @@ def initialize( context ): ...@@ -1200,8 +1216,13 @@ def initialize( context ):
""" """
path = os.path.join(getConfiguration().instancehome, 'tests') path = os.path.join(getConfiguration().instancehome, 'tests')
verbosity = verbose and 2 or 1 verbosity = verbose and 2 or 1
return runLiveTest(test_list, run_only=run_only, debug=debug, path=path, instance_home = getConfiguration().instancehome
verbosity=verbosity) global global_stream
global_stream = StringIO()
result = runLiveTest(test_list, run_only=run_only, debug=debug, path=path,
stream=global_stream, verbosity=verbosity)
global_stream.seek(0)
return global_stream.read()
def getProductList(self): def getProductList(self):
""" List all products """ """ List all products """
......
...@@ -444,7 +444,7 @@ class ERP5TypeLiveTestCase(ProcessingNodeTestCase, PortalTestCase): ...@@ -444,7 +444,7 @@ class ERP5TypeLiveTestCase(ProcessingNodeTestCase, PortalTestCase):
return ResponseWrapper(response, outstream, path) return ResponseWrapper(response, outstream, path)
def runLiveTest(test_list, verbosity=1, **kw): def runLiveTest(test_list, verbosity=1, stream=None, **kw):
from Products.ERP5Type.tests.runUnitTest import DebugTestResult from Products.ERP5Type.tests.runUnitTest import DebugTestResult
from Products.ERP5Type.tests.runUnitTest import ERP5TypeTestLoader from Products.ERP5Type.tests.runUnitTest import ERP5TypeTestLoader
from Products.ERP5Type.tests import backportUnittest from Products.ERP5Type.tests import backportUnittest
...@@ -472,9 +472,8 @@ def runLiveTest(test_list, verbosity=1, **kw): ...@@ -472,9 +472,8 @@ def runLiveTest(test_list, verbosity=1, **kw):
ERP5TypeTestLoader.filter_test_list = [re.compile(x).search ERP5TypeTestLoader.filter_test_list = [re.compile(x).search
for x in run_only.split(',')] for x in run_only.split(',')]
suite = ERP5TypeTestLoader().loadTestsFromNames(test_list) suite = ERP5TypeTestLoader().loadTestsFromNames(test_list)
stream = StringIO() output = stream
output = StringIO() if stream is None:
output = StringIO()
output.write("**Running Live Test:\n") output.write("**Running Live Test:\n")
result = TestRunner(stream=output, verbosity=verbosity).run(suite) result = TestRunner(stream=output, verbosity=verbosity).run(suite)
output.write(stream.getvalue())
return output.getvalue()
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