From 41fea2f8923036621c209afebf32c912d5c637e4 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Wed, 1 Apr 2026 21:06:10 +0200 Subject: [PATCH] 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 --- tests/integration/api_exec_test.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/integration/api_exec_test.py b/tests/integration/api_exec_test.py index 5b829e2875..15080907c4 100644 --- a/tests/integration/api_exec_test.py +++ b/tests/integration/api_exec_test.py @@ -286,13 +286,9 @@ def test_exec_command_tty_stream_no_demux(self): # tty=True, stream=True, demux=False res = self.client.exec_create(self.container, self.cmd, tty=True) exec_log = list(self.client.exec_start(res, stream=True)) - assert b'hello out\r\n' in exec_log - if len(exec_log) == 2: - assert b'hello err\r\n' in exec_log - else: - assert len(exec_log) == 3 - assert b'hello err' in exec_log - assert b'\r\n' in exec_log + merged = b''.join(chunk for chunk in exec_log) + assert b'hello out\r\n' in merged + assert b'hello err\r\n' in merged def test_exec_command_tty_no_stream_demux(self): # tty=True, stream=False, demux=True @@ -304,10 +300,6 @@ def test_exec_command_tty_stream_demux(self): # tty=True, stream=True, demux=True res = self.client.exec_create(self.container, self.cmd, tty=True) exec_log = list(self.client.exec_start(res, demux=True, stream=True)) - assert (b'hello out\r\n', None) in exec_log - if len(exec_log) == 2: - assert (b'hello err\r\n', None) in exec_log - else: - assert len(exec_log) == 3 - assert (b'hello err', None) in exec_log - assert (b'\r\n', None) in exec_log + merged = b''.join(chunk for chunk, _ in exec_log) + assert b'hello out\r\n' in merged + assert b'hello err\r\n' in merged