Skip to content

Commit

Permalink
Merge branch 'master' into acl-commands
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/about/changelog.md
  • Loading branch information
cunla committed Dec 18, 2024
2 parents 443bfee + 0afe9a5 commit adfec14
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ toc_depth: 2
### 🚀 Features

- ACL commands support #338
- Add support disable_decoding in async read_response #349


### 🧰 Maintenance

Expand Down
2 changes: 2 additions & 0 deletions fakeredis/aioredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ async def read_response(self, **kwargs: Any) -> Any: # type: ignore
response = await self._reader.read(0) if can_read and self._reader else None
if isinstance(response, redis_async.ResponseError):
raise response
if kwargs.get("disable_decoding", False):
return response
return self._decode(response)

def repr_pieces(self) -> List[Tuple[str, Any]]:
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages = [
{ include = "fakeredis" },
{ include = "LICENSE", to = "fakeredis" },
]
version = "2.26.2"
version = "2.27.0"
description = "Python implementation of redis API, can be used for testing purposes."
readme = "README.md"
keywords = ["redis", "RedisJson", "RedisBloom", "tests", "redis-stack"]
Expand Down
6 changes: 4 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ async def _req_aioredis2(request) -> redis.asyncio.Redis:
server_type, server_version = request.getfixturevalue("real_redis_version")
if request.param != "fake" and not server_version:
pytest.skip("Redis is not running")

decode_responses = bool(request.node.get_closest_marker("decode_responses"))
unsupported_server_types = request.node.get_closest_marker("unsupported_server_types")
if unsupported_server_types and server_type in unsupported_server_types.args:
pytest.skip(f"Server type {server_type} is not supported")
Expand All @@ -131,9 +133,9 @@ async def _req_aioredis2(request) -> redis.asyncio.Redis:
fake_server: Optional[fakeredis.FakeServer]
if request.param == "fake":
fake_server = request.getfixturevalue("fake_server")
ret = fakeredis.FakeAsyncRedis(server=fake_server, lua_modules=lua_modules)
ret = fakeredis.FakeAsyncRedis(server=fake_server, lua_modules=lua_modules, decode_responses=decode_responses)
else:
ret = redis.asyncio.Redis(host="localhost", port=6390, db=2)
ret = redis.asyncio.Redis(host="localhost", port=6390, db=2, decode_responses=decode_responses)
fake_server = None
if not fake_server or fake_server.connected:
await ret.flushall()
Expand Down
11 changes: 11 additions & 0 deletions test/test_asyncredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ async def test_syntax_error(async_redis: redis.asyncio.Redis):
await async_redis.execute_command("get")


@pytest.mark.decode_responses
async def test_never_decode(async_redis: redis.asyncio.Redis):
assert async_redis.connection_pool.get_encoder().decode_responses

await async_redis.execute_command("set", "key", "some ascii")
text = await async_redis.execute_command("get", "key")
assert isinstance(text, str)
bytestr = await async_redis.execute_command("get", "key", NEVER_DECODE=True)
assert isinstance(bytestr, bytes)


@testtools.run_test_if_lupa
class TestScripts:
async def test_no_script_error(self, async_redis: redis.asyncio.Redis):
Expand Down

0 comments on commit adfec14

Please sign in to comment.