Skip to content

Commit fbb851e

Browse files
authored
Fix instance info tests for redis. (#784)
* Fix instance info tests for redis. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai <[email protected]>
1 parent df9701c commit fbb851e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/datastore_redis/test_instance_info.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def test_strict_redis_connection_instance_info(args, kwargs, expected):
100100
if (3, 5, 3) >= REDIS_PY_VERSION >= (2, 7, 5):
101101
_instance_info_from_url_tests.append((("redis://127.0.0.1",), {}, ("127.0.0.1", "6379", "0")))
102102

103+
103104
if REDIS_PY_VERSION >= (2, 10):
104105
_instance_info_from_url_tests.extend(
105106
[
@@ -115,6 +116,13 @@ def test_strict_redis_connection_instance_info(args, kwargs, expected):
115116
]
116117
)
117118

119+
if REDIS_PY_VERSION >= (4, 5, 2):
120+
_instance_info_from_url_tests_4_5_2 = _instance_info_from_url_tests[:-3] + [
121+
(("unix:///path/to/socket.sock",), {}, ("localhost", "6379", "0")),
122+
(("unix:///path/to/socket.sock?db=2",), {}, ("localhost", "6379", "2")),
123+
(("unix:///path/to/socket.sock",), {"db": 2}, ("localhost", "6379", "2")),
124+
]
125+
118126

119127
@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
120128
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
@@ -133,7 +141,10 @@ def test_strict_redis_client_from_url(args, kwargs, expected):
133141

134142

135143
@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
136-
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
144+
@pytest.mark.parametrize(
145+
"args,kwargs,expected",
146+
_instance_info_from_url_tests if REDIS_PY_VERSION < (4, 5, 2) else _instance_info_from_url_tests_4_5_2,
147+
)
137148
def test_redis_connection_from_url(args, kwargs, expected):
138149
r = redis.Redis.from_url(*args, **kwargs)
139150
if r.connection_pool.connection_class is redis.Connection:
@@ -153,7 +164,10 @@ def test_redis_connection_from_url(args, kwargs, expected):
153164

154165

155166
@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
156-
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
167+
@pytest.mark.parametrize(
168+
"args,kwargs,expected",
169+
_instance_info_from_url_tests if REDIS_PY_VERSION < (4, 5, 2) else _instance_info_from_url_tests_4_5_2,
170+
)
157171
def test_strict_redis_connection_from_url(args, kwargs, expected):
158172
r = redis.StrictRedis.from_url(*args, **kwargs)
159173
if r.connection_pool.connection_class is redis.Connection:

0 commit comments

Comments
 (0)