diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2022-10-30 11:39:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-30 13:39:41 +0200 |
commit | 16270e4bb5fcaebe8a8992fc2b2ccbd9d57b8c3e (patch) | |
tree | e83a05a63e58a7d172181a41d4206f58fa505839 /tests | |
parent | 842634e7fddeb32ba20aab0dacf557a958a4b00b (diff) | |
download | redis-py-16270e4bb5fcaebe8a8992fc2b2ccbd9d57b8c3e.tar.gz |
Remove the superflous SocketBuffer from asyncio PythonParser (#2418)
* Remove buffering from asyncio SocketBuffer and rely on on the underlying StreamReader
* Skip the use of SocketBuffer in PythonParser
* Remove SocketBuffer altogether
* Code cleanup
* Fix unittest mocking when SocketBuffer is gone
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_asyncio/test_connection.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/test_asyncio/test_connection.py b/tests/test_asyncio/test_connection.py index 674a1b9..6bf0034 100644 --- a/tests/test_asyncio/test_connection.py +++ b/tests/test_asyncio/test_connection.py @@ -13,22 +13,23 @@ from redis.asyncio.connection import ( from redis.asyncio.retry import Retry from redis.backoff import NoBackoff from redis.exceptions import ConnectionError, InvalidResponse, TimeoutError -from redis.utils import HIREDIS_AVAILABLE from tests.conftest import skip_if_server_version_lt from .compat import mock @pytest.mark.onlynoncluster -@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only") async def test_invalid_response(create_redis): r = await create_redis(single_connection_client=True) raw = b"x" - readline_mock = mock.AsyncMock(return_value=raw) parser: "PythonParser" = r.connection._parser - with mock.patch.object(parser._buffer, "readline", readline_mock): + if not isinstance(parser, PythonParser): + pytest.skip("PythonParser only") + stream_mock = mock.Mock(parser._stream) + stream_mock.readline.return_value = raw + b"\r\n" + with mock.patch.object(parser, "_stream", stream_mock): with pytest.raises(InvalidResponse) as cm: await parser.read_response() assert str(cm.value) == f"Protocol Error: {raw!r}" |