From: Peter Pentchev Date: Sat, 18 Mar 2023 20:43:56 +0000 (+0200) Subject: Simplify line splitting in the CLI tests X-Git-Tag: v1.5.5~2^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b001a38fea0a78e6d6a9ce73f9c0ab9459d6341;p=thirdparty%2Fzstd.git Simplify line splitting in the CLI tests --- diff --git a/tests/cli-tests/run.py b/tests/cli-tests/run.py index 108f71019..9306f8a09 100755 --- a/tests/cli-tests/run.py +++ b/tests/cli-tests/run.py @@ -114,20 +114,12 @@ def pop_line(data: bytes) -> typing.Tuple[typing.Optional[bytes], bytes]: 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 not line.endswith(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: