From ea117304779b456f7a695bcfa0708c0df551729e Mon Sep 17 00:00:00 2001 From: David Martinez Gil <77310250+Bicheka@users.noreply.github.com> Date: Thu, 15 Aug 2024 02:23:39 -0400 Subject: [PATCH] fix(bindings/python): Make sure read until EOF (#4995) * Fix #4990 guarantees read until EOF * Address code review feedback for solving issue #4990 * Fix: Ensure full content is read before performing assertions This commit addresses the issue raised in the pull request #4989, where the `read()` operation did not always return the expected content length. Changes include: - Implementing a loop to gather all content chunks until EOF. - Performing the assertion after the entire content has been read. This ensures that the test passes stably by correctly handling cases where `read()` may not return the full content in one go. * address pr code review comment * addressed pr code review by deleting requested code in my pr --- bindings/python/tests/test_read.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bindings/python/tests/test_read.py b/bindings/python/tests/test_read.py index dd19e56abc68..aa4b8711fb49 100644 --- a/bindings/python/tests/test_read.py +++ b/bindings/python/tests/test_read.py @@ -54,7 +54,14 @@ def test_sync_reader(service_name, operator, async_operator): assert read_content == content with operator.open(filename, "rb") as reader: - read_content = reader.read(size + 1) + read_content = bytearray() + while True: + chunk = reader.read(size + 1) + if not chunk: + break + read_content.extend(chunk) + + read_content = bytes(read_content) assert read_content is not None assert read_content == content