test_console_output: Implement the entire TextIO contract.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-12-22 21:55:47 -08:00
committed by Tim Abbott
parent 702ce071f4
commit d40f3d54f1
2 changed files with 135 additions and 84 deletions

View File

@@ -68,8 +68,8 @@ from zerver.lib.streams import (
from zerver.lib.test_console_output import (
ExtraConsoleOutputFinder,
ExtraConsoleOutputInTestException,
TeeStderrAndFindExtraConsoleOutput,
TeeStdoutAndFindExtraConsoleOutput,
tee_stderr_and_find_extra_console_output,
tee_stdout_and_find_extra_console_output,
)
from zerver.lib.test_helpers import find_key_by_email, instrument_url
from zerver.lib.users import get_api_key
@@ -168,9 +168,9 @@ class ZulipTestCase(TestCase):
if not settings.BAN_CONSOLE_OUTPUT:
return super().run(result)
extra_output_finder = ExtraConsoleOutputFinder()
with TeeStderrAndFindExtraConsoleOutput(
with tee_stderr_and_find_extra_console_output(
extra_output_finder
), TeeStdoutAndFindExtraConsoleOutput(extra_output_finder):
), tee_stdout_and_find_extra_console_output(extra_output_finder):
test_result = super().run(result)
if extra_output_finder.full_extra_output:
exception_message = f"""
@@ -189,7 +189,7 @@ You should be able to quickly reproduce this failure with:
test-backend --ban-console-output {self.id()}
Output:
{extra_output_finder.full_extra_output}
{extra_output_finder.full_extra_output.decode(errors="replace")}
--------------------------------------------
"""
raise ExtraConsoleOutputInTestException(exception_message)