summaryrefslogtreecommitdiff
path: root/tests/test_connection.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_connection.py')
-rw-r--r--tests/test_connection.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 0071aca..22f1b71 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -1,37 +1,40 @@
-from unittest import mock
import types
+from unittest import mock
+
import pytest
from redis.exceptions import InvalidResponse
from redis.utils import HIREDIS_AVAILABLE
+
from .conftest import skip_if_server_version_lt
-@pytest.mark.skipif(HIREDIS_AVAILABLE, reason='PythonParser only')
+@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@pytest.mark.onlynoncluster
def test_invalid_response(r):
- raw = b'x'
+ raw = b"x"
parser = r.connection._parser
- with mock.patch.object(parser._buffer, 'readline', return_value=raw):
+ with mock.patch.object(parser._buffer, "readline", return_value=raw):
with pytest.raises(InvalidResponse) as cm:
parser.read_response()
- assert str(cm.value) == f'Protocol Error: {raw!r}'
+ assert str(cm.value) == f"Protocol Error: {raw!r}"
-@skip_if_server_version_lt('4.0.0')
+@skip_if_server_version_lt("4.0.0")
@pytest.mark.redismod
def test_loading_external_modules(modclient):
def inner():
pass
- modclient.load_external_module('myfuncname', inner)
- assert getattr(modclient, 'myfuncname') == inner
- assert isinstance(getattr(modclient, 'myfuncname'), types.FunctionType)
+ modclient.load_external_module("myfuncname", inner)
+ assert getattr(modclient, "myfuncname") == inner
+ assert isinstance(getattr(modclient, "myfuncname"), types.FunctionType)
# and call it
from redis.commands import RedisModuleCommands
+
j = RedisModuleCommands.json
- modclient.load_external_module('sometestfuncname', j)
+ modclient.load_external_module("sometestfuncname", j)
# d = {'hello': 'world!'}
# mod = j(modclient)