From f74cfe0ed5c389d65f0cf03409b9af0de1894955 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 25 Apr 2023 17:51:26 -0700 Subject: [PATCH] test_console_output: Fix WrappedIO.writelines with iterator. Signed-off-by: Anders Kaseorg --- zerver/lib/test_console_output.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zerver/lib/test_console_output.py b/zerver/lib/test_console_output.py index a0561168df..e149dd1a06 100644 --- a/zerver/lib/test_console_output.py +++ b/zerver/lib/test_console_output.py @@ -1,3 +1,4 @@ +import itertools import logging import re import sys @@ -102,8 +103,9 @@ class WrappedIO(IO[bytes]): return num_chars def writelines(self, data: Iterable[bytes]) -> None: + data, data_copy = itertools.tee(data) self.stream.writelines(data) - lines = b"".join(data) + lines = b"".join(data_copy) self.extra_output_finder.find_extra_output(lines) def __next__(self) -> bytes: