Commit 15a702e8 authored by Jérome Perrin's avatar Jérome Perrin

ERP5TypeLiveTestCase: repair live test output no longer in console

This was a regression from 9a7e3383 (Do not overwrite `output.write`
in live tests., 2024-04-10), we missed that `output` was also passed
to TestRunner to run the suite
parent ae22fb6e
...@@ -291,12 +291,18 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, ** ...@@ -291,12 +291,18 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **
output = stream output = stream
if stream is None: if stream is None:
output = StringIO() output = StringIO()
def print_and_write(data): class StderrIOWrapper:
def __init__(self, wrapped):
self._wrapped_io = wrapped
def write(self, data):
sys.stderr.write(data) sys.stderr.write(data)
sys.stderr.flush() return self._wrapped_io.write(data)
return output.write(data) def __getattr__(self, attr):
print_and_write("**Running Live Test:\n") return getattr(self._wrapped_io, attr)
ZopeTestCase._print = print_and_write
output = StderrIOWrapper(output)
output.write("**Running Live Test:\n")
ZopeTestCase._print = output.write
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter(kw['warnings']) warnings.simplefilter(kw['warnings'])
...@@ -306,6 +312,6 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, ** ...@@ -306,6 +312,6 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **
from AccessControl.SecurityManagement import getSecurityManager, setSecurityManager from AccessControl.SecurityManagement import getSecurityManager, setSecurityManager
sm = getSecurityManager() sm = getSecurityManager()
try: try:
result = TestRunner(stream=output, verbosity=verbosity).run(suite) TestRunner(stream=output, verbosity=verbosity).run(suite)
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
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