Commit 163582bf authored by Jérome Perrin's avatar Jérome Perrin

use low-level RESPONSE.write and RESPONSE.flush to flush output in runUnitTestList



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10027 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2d46ed0b
...@@ -417,15 +417,32 @@ class TemplateTool (BaseTool): ...@@ -417,15 +417,32 @@ class TemplateTool (BaseTool):
elif (batch_mode == 1): elif (batch_mode == 1):
return bt return bt
def runUnitTestList(self, test_list=[], **kwd): security.declareProtected(Permissions.ManagePortal, 'runUnitTestList')
""" def runUnitTestList(self, test_list=[],
Runs Unit Tests related to this Business Template 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 for file presence before trying to execute.
# XXX: should check if the unit test file is configured in the BT # XXX: should check if the unit test file is configured in the BT
from Products.ERP5Type.tests.runUnitTest import getUnitTestFile from Products.ERP5Type.tests.runUnitTest import getUnitTestFile
return os.popen('/usr/bin/python %s %s 2>&1' if RESPONSE is not None:
% (getUnitTestFile(), ' '.join(test_list))).read() 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): def diffObject(self, REQUEST, **kw):
""" """
......
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