diff --git a/tests/cli-tests/run.py b/tests/cli-tests/run.py index a2e1c1f86df..9306f8a094d 100755 --- a/tests/cli-tests/run.py +++ b/tests/cli-tests/run.py @@ -109,25 +109,17 @@ def pop_line(data: bytes) -> typing.Tuple[typing.Optional[bytes], bytes]: the first line always ends in a :\n:, even if it is the last line and :data: doesn't end in :\n:. """ - NEWLINE = b"\n"[0] + NEWLINE = b"\n" if data == b'': return (None, data) - newline_idx = data.find(b"\n") - if newline_idx == -1: - end_idx = len(data) - else: - end_idx = newline_idx + 1 - - line = data[:end_idx] - data = data[end_idx:] - - assert len(line) != 0 - if line[-1] != NEWLINE: - line += NEWLINE + parts = data.split(NEWLINE, maxsplit=1) + line = parts[0] + NEWLINE + if len(parts) == 1: + return line, b'' - return (line, data) + return line, parts[1] def glob_line_matches(actual: bytes, expect: bytes) -> bool: