Skip to content

Commit b8f992f

Browse files
committed
fix:removing use of self.protocol to support redis-py<5
1 parent 91ee4af commit b8f992f

File tree

5 files changed

+122
-95
lines changed

5 files changed

+122
-95
lines changed

docs/about/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ tags:
77
toc_depth: 2
88
---
99

10+
## v2.31.4 -
11+
12+
### 🐛 Bug Fixes
13+
14+
- fix:removing use of self.protocol to support redis-py < 5 #419
15+
1016
## v2.31.3 -
1117

1218
### 🐛 Bug Fixes

fakeredis/_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def connect(self) -> None:
2424
def _connect(self) -> FakeSocket:
2525
if not self._server.connected:
2626
raise redis.ConnectionError(msgs.CONNECTION_ERROR_MSG)
27+
protocol = getattr(self, "protocol", 2)
2728
return FakeSocket(
2829
self._server,
2930
client_class=self._client_class,
@@ -56,7 +57,7 @@ def _connect(self) -> FakeSocket:
5657
cmd="auth",
5758
user="default",
5859
redir=-1,
59-
resp=self.protocol,
60+
resp=protocol,
6061
),
6162
)
6263

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "fakeredis"
7-
version = "2.31.3"
7+
version = "2.31.4"
88
description = "Python implementation of redis API, can be used for testing purposes."
99
authors = [
1010
{ name = "Daniel Moran", email = "daniel@moransoftware.ca" },

test/test_internals/test_init_args.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def test_from_url(self):
6767
db.set("foo", "bar")
6868
assert db.get("foo") == b"bar"
6969

70+
def test_from_url_ping(self):
71+
client = fakeredis.FakeRedis.from_url("redis://localhost:6390/0")
72+
client.ping()
73+
7074
def test_from_url_user(self):
7175
username = "fakeredis-user"
7276
db = fakeredis.FakeStrictRedis(host="localhost", port=6390, db=0)

0 commit comments

Comments
 (0)