Commit 9a7e3383 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Do not overwrite `output.write` in live tests.

The `write` method of the `output` object was being overwritten
in live tests, replacing it to a function that printed both to
the output and to stdout. This was not necessary, as it is
possible to use this function directly. Moreover, the function
code had two flaws:
  - It assumed that output was a particular (StringIO) class.
  This caused a problem during the migration (commit
  80bd30fc820d273d18d9c54566137301d9c40a4c).
  - It printed to stdout instead to stderr.
Using the function directly allows `output.write` to be used
inside it, preventing the first flaw. The second flaw has also
been solved.
parent 6dad9f33
...@@ -291,12 +291,11 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, ** ...@@ -291,12 +291,11 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **
if stream is None: if stream is None:
output = StringIO() output = StringIO()
def print_and_write(data): def print_and_write(data):
sys.stdout.write(data) sys.stderr.write(data)
sys.stdout.flush() sys.stderr.flush()
return StringIO.write(output, data) return output.write(data)
output.write = print_and_write print_and_write("**Running Live Test:\n")
output.write("**Running Live Test:\n") ZopeTestCase._print = print_and_write
ZopeTestCase._print = output.write
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter(kw['warnings']) warnings.simplefilter(kw['warnings'])
......
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