Skip to content

Commit 41fea2f

Browse files
tests: Make stream assertions robust to chunk splitting
When tty=True the output can be split across multiple stream chunks instead of aligning on line boundaries, making exact chunk membership checks unreliable. Verify that the expected messages are present in the combined stream output rather than at specific chunk boundaries. Signed-off-by: Ricardo Branco <rbranco@suse.de>
1 parent df3f8e2 commit 41fea2f

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

tests/integration/api_exec_test.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,9 @@ def test_exec_command_tty_stream_no_demux(self):
286286
# tty=True, stream=True, demux=False
287287
res = self.client.exec_create(self.container, self.cmd, tty=True)
288288
exec_log = list(self.client.exec_start(res, stream=True))
289-
assert b'hello out\r\n' in exec_log
290-
if len(exec_log) == 2:
291-
assert b'hello err\r\n' in exec_log
292-
else:
293-
assert len(exec_log) == 3
294-
assert b'hello err' in exec_log
295-
assert b'\r\n' in exec_log
289+
merged = b''.join(chunk for chunk in exec_log)
290+
assert b'hello out\r\n' in merged
291+
assert b'hello err\r\n' in merged
296292

297293
def test_exec_command_tty_no_stream_demux(self):
298294
# tty=True, stream=False, demux=True
@@ -304,10 +300,6 @@ def test_exec_command_tty_stream_demux(self):
304300
# tty=True, stream=True, demux=True
305301
res = self.client.exec_create(self.container, self.cmd, tty=True)
306302
exec_log = list(self.client.exec_start(res, demux=True, stream=True))
307-
assert (b'hello out\r\n', None) in exec_log
308-
if len(exec_log) == 2:
309-
assert (b'hello err\r\n', None) in exec_log
310-
else:
311-
assert len(exec_log) == 3
312-
assert (b'hello err', None) in exec_log
313-
assert (b'\r\n', None) in exec_log
303+
merged = b''.join(chunk for chunk, _ in exec_log)
304+
assert b'hello out\r\n' in merged
305+
assert b'hello err\r\n' in merged

0 commit comments

Comments
 (0)