File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 13
13
from redis .asyncio .retry import Retry
14
14
from redis .backoff import NoBackoff
15
15
from redis .exceptions import ConnectionError , InvalidResponse , TimeoutError
16
- from redis .utils import HIREDIS_AVAILABLE
17
16
from tests .conftest import skip_if_server_version_lt
18
17
19
18
from .compat import mock
20
19
21
20
22
21
@pytest .mark .onlynoncluster
23
- @pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
24
22
async def test_invalid_response (create_redis ):
25
23
r = await create_redis (single_connection_client = True )
26
24
27
25
raw = b"x"
28
- readline_mock = mock .AsyncMock (return_value = raw )
29
26
30
27
parser : "PythonParser" = r .connection ._parser
31
- with mock .patch .object (parser ._buffer , "readline" , readline_mock ):
28
+ if not isinstance (parser , PythonParser ):
29
+ pytest .skip ("PythonParser only" )
30
+ stream_mock = mock .Mock (parser ._stream )
31
+ stream_mock .readline .return_value = raw + b"\r \n "
32
+ with mock .patch .object (parser , "_stream" , stream_mock ):
32
33
with pytest .raises (InvalidResponse ) as cm :
33
34
await parser .read_response ()
34
35
assert str (cm .value ) == f"Protocol Error: { raw !r} "
You can’t perform that action at this time.
0 commit comments