[Erp5-report] r10027 - /erp5/trunk/products/ERP5/Tool/TemplateTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Sep 16 13:57:37 CEST 2006
Author: jerome
Date: Sat Sep 16 13:57:34 2006
New Revision: 10027
URL: http://svn.erp5.org?rev=10027&view=rev
Log:
use low-level RESPONSE.write and RESPONSE.flush to flush output in runUnitTestList
Modified:
erp5/trunk/products/ERP5/Tool/TemplateTool.py
Modified: erp5/trunk/products/ERP5/Tool/TemplateTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TemplateTool.py?rev=10027&r1=10026&r2=10027&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py Sat Sep 16 13:57:34 2006
@@ -417,15 +417,32 @@
elif (batch_mode == 1):
return bt
- def runUnitTestList(self, test_list=[], **kwd):
- """
- Runs Unit Tests related to this Business Template
+ security.declareProtected(Permissions.ManagePortal, 'runUnitTestList')
+ def runUnitTestList(self, test_list=[],
+ REQUEST=None, RESPONSE=None, **kwd):
+ """Runs Unit Tests related to this Business Template
"""
# XXX: should check for file presence before trying to execute.
# XXX: should check if the unit test file is configured in the BT
from Products.ERP5Type.tests.runUnitTest import getUnitTestFile
- return os.popen('/usr/bin/python %s %s 2>&1'
- % (getUnitTestFile(), ' '.join(test_list))).read()
+ if RESPONSE is not None:
+ outfile = RESPONSE
+ elif REQUEST is not None:
+ outfile = RESPONSE = REQUEST.RESPONSE
+ else:
+ outfile = StringIO()
+ if RESPONSE is not None:
+ RESPONSE.setHeader('Content-type', 'text/plain')
+ process = os.popen('/usr/bin/python %s %s 2>&1'
+ % (getUnitTestFile(), ' '.join(test_list)))
+ while 1:
+ try:
+ outfile.write(process.next())
+ outfile.flush()
+ except StopIteration:
+ break
+ if hasattr(outfile, 'getvalue'):
+ return outfile.getvalue()
def diffObject(self, REQUEST, **kw):
"""
More information about the Erp5-report
mailing list