This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new ea11730477 fix(bindings/python): Make sure read until EOF (#4995)
ea11730477 is described below
commit ea117304779b456f7a695bcfa0708c0df551729e
Author: David Martinez Gil <[email protected]>
AuthorDate: Thu Aug 15 02:23:39 2024 -0400
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 dd19e56abc..aa4b8711fb 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