[Erp5-report] r39388 seb - in /erp5/trunk/products/ERP5Type: Tool/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Oct 20 13:26:08 CEST 2010


Author: seb
Date: Wed Oct 20 13:26:07 2010
New Revision: 39388

URL: http://svn.erp5.org?rev=39388&view=rev
Log:
prepare methods to allows dynamic display of results
in browser through jquery

Modified:
    erp5/trunk/products/ERP5Type/Tool/ClassTool.py
    erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py

Modified: erp5/trunk/products/ERP5Type/Tool/ClassTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/ClassTool.py?rev=39388&r1=39387&r2=39388&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] Wed Oct 20 13:26:07 2010
@@ -37,6 +37,7 @@ from Products.CMFCore.utils import Uniqu
 
 import OFS
 import transaction
+from cStringIO import StringIO
 from zExceptions import BadRequest
 from zExceptions import Unauthorized
 from Acquisition import Implicit
@@ -72,6 +73,8 @@ import Products
 
 from zLOG import LOG, WARNING
 
+global_stream = None
+
 """
   ClassTool allows to create classes from the ZMI using code templates.
   ZMI-created classes can then be edited again.
@@ -1187,6 +1190,19 @@ def initialize( context ):
                              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')
       def runLiveTest(self, test_list=[], run_only=None, debug=None,
                       verbose=False):
         """
@@ -1200,8 +1216,13 @@ def initialize( context ):
         """
         path = os.path.join(getConfiguration().instancehome, 'tests')
         verbosity = verbose and 2 or 1
-        return runLiveTest(test_list, run_only=run_only, debug=debug, path=path,
-                           verbosity=verbosity)
+        instance_home = getConfiguration().instancehome
+        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):
         """ List all products """

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py?rev=39388&r1=39387&r2=39388&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py [utf8] Wed Oct 20 13:26:07 2010
@@ -444,7 +444,7 @@ class ERP5TypeLiveTestCase(ProcessingNod
 
         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 ERP5TypeTestLoader
   from Products.ERP5Type.tests import backportUnittest
@@ -472,9 +472,8 @@ def runLiveTest(test_list, verbosity=1, 
     ERP5TypeTestLoader.filter_test_list = [re.compile(x).search
                                             for x in run_only.split(',')]
   suite = ERP5TypeTestLoader().loadTestsFromNames(test_list)
-  stream = StringIO()
-  output = StringIO()
+  output = stream
+  if stream is None:
+    output = StringIO()
   output.write("**Running Live Test:\n")
   result = TestRunner(stream=output, verbosity=verbosity).run(suite)
-  output.write(stream.getvalue())
-  return output.getvalue()




More information about the Erp5-report mailing list