[Erp5-report] r38051 seb - in /erp5/trunk/products/ERP5Type: Tool/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Aug 27 10:15:26 CEST 2010
Author: seb
Date: Fri Aug 27 10:15:23 2010
New Revision: 38051
URL: http://svn.erp5.org?rev=38051&view=rev
Log:
* add method runLiveTest in portal_classes
* add some features of runUnitTest in runLiveTest :
- run_only option
- debug option
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=38051&r1=38050&r2=38051&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] Fri Aug 27 10:15:23 2010
@@ -1178,6 +1178,19 @@ def initialize( context ):
writeLocalConstraint(class_id, text, create=create,
instance_home=self._v_instance_home.getPath())
+ security.declareProtected(Permissions.ManagePortal, 'runLiveTest')
+ def runLiveTest(self, test_list=[], run_only=None, debug=None):
+ """
+ Launch live tests
+
+ run_only=STRING Run only specified test methods delimited with
+ commas (e.g. testFoo,testBar). This can be regular
+ expressions.
+ debug=boolean Invoke debugger on errors / failures.
+ """
+ path = os.path.join(getConfiguration().instancehome, 'tests')
+ return runLiveTest(test_list, run_only=run_only, debug=debug, path=path)
+
else:
class ClassTool(BaseTool, ClassToolMixIn):
Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py?rev=38051&r1=38050&r2=38051&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeLiveTestCase.py [utf8] Fri Aug 27 10:15:23 2010
@@ -88,6 +88,8 @@ class ERP5TypeLiveTestCase(ProcessingNod
"""
# Assumes that portal exists (which has sense) and that there is only one
# ERP5 site in Zope (which is always the case)
+ if self.app.meta_type == 'ERP5 Site':
+ return self.app
return [q for q in self.app.objectValues() if q.meta_type == 'ERP5 Site'
][0]
@@ -435,12 +437,34 @@ class ERP5TypeLiveTestCase(ProcessingNod
return ResponseWrapper(response, outstream, path)
-def runLiveTest(self, suite):
+def runLiveTest(test_list, **kw):
+ from Products.ERP5Type.tests.runUnitTest import DebugTestResult
from Products.ERP5Type.tests.runUnitTest import ERP5TypeTestLoader
from Products.ERP5Type.tests import backportUnittest
from StringIO import StringIO
+ import imp
+ import re
+ # Add path of the TestTemplateItem folder of the instance
+ path = kw.get('path', None)
+ if path is not None and path not in sys.path:
+ sys.path.append(path)
+ # Reload the test class before runing tests
+ for test_name in test_list:
+ (test_file, test_path_name, test_description) = imp.find_module(test_name)
+ imp.load_module(test_name, test_file, test_path_name, test_description)
+
TestRunner = backportUnittest.TextTestRunner
- unittest.TestLoader = ERP5TypeTestLoader
+ if kw.get('debug', False):
+ class DebugTextTestRunner(TestRunner):
+ def _makeResult(self):
+ result = super(DebugTextTestRunner, self)._makeResult()
+ return DebugTestResult(result)
+ TestRunner = DebugTextTestRunner
+ run_only = kw.get('run_only', None)
+ if run_only is not None:
+ ERP5TypeTestLoader.filter_test_list = [re.compile(x).search
+ for x in run_only.split(',')]
+ suite = ERP5TypeTestLoader().loadTestsFromNames(test_list)
stream = StringIO()
output = StringIO()
output.write("**Running Live Test:\n")
More information about the Erp5-report
mailing list