Skip to content

bug: python's test doesn't use reader correctly #4990

@Xuanwo

Description

@Xuanwo

Describe the bug

with operator.open(filename, "rb") as reader:
assert reader.readable()
assert not reader.writable()
assert not reader.closed
read_content = reader.read()
assert read_content is not None
assert read_content == content
with operator.open(filename, "rb") as reader:
read_content = reader.read(size + 1)
assert read_content is not None
assert read_content == content

There is no guarantee that read will always fill the read size. Users should keep calling read until EOF.

Steps to Reproduce

https://github.com/apache/opendal/actions/runs/10321553970/job/28574789953?pr=4989

The content is short than expected.

Expected Behavior

This test should pass stably.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions