Skip to content

Commit

Permalink
fix(bindings/python): Make sure read until EOF (#4995)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Bicheka authored Aug 15, 2024
1 parent 50dc066 commit ea11730
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bindings/python/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ea11730

Please sign in to comment.