Skip to content

Discrepancy when using xread #393

@EndreSzakal

Description

@EndreSzakal

Describe the bug
I am using the xadd and xread (redis streams) commands with FakeAsyncRedis, and I am getting a slightly different object from xread with fakeredis compared to redis-py.

The difference seems to be that redis-py produces a dictionary of stream_keys, while fakeredis provides a doubly nested list.

I just started using fakeredis and like it a lot, so let me know if this is fixable or is one of those discrepancies. Thx!

To Reproduce
xread with fakeredis:

fake_redis = FakeAsyncRedis(host="localhost", port=6379, decode_responses=True, protocol=3)
stream_key = "test_stream"
await fake_redis.xadd(stream_key, fields={"chunk": "Some Data"})
stream_read = await fake_redis.xread(streams={stream_key: "0-0"}, block=0)
stream_read

"""
[
    [
        'test_stream',
        [
            ('1749650862902-0', {'chunk': 'Some Data'})
        ]
    ]
]
"""

xread with redis-py:

from redis.asyncio import Redis
redis = Redis(host="localhost", port=6379, decode_responses=True, protocol=3)
stream_key = "test_stream"
await redis.xadd(stream_key, fields={"chunk": "Some Data"})
stream_read = await redis.xread(streams={stream_key: "0-0"}, block=0)
stream_read

"""
{
    'test_stream': [
        [
            ('1749650862654-0', {'chunk': 'Some Data'})
        ]
    ]
}
"""

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

Desktop (please complete the following information):
OS: Debian 12
python==3.13.4
redis-py==6.2.0
fakeredis==2.29.0

redis docker image: redis:latest or sha256:ad628d213d00627d78094bd0da550d7abb59649e2c8fda74eed4c80794a577dc

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions