Skip to content

Commit 047f1ba

Browse files
test: align keyspace test with fakeredis fixture requirements
Use the standard fixture to test against both RESP2 and RESP3 on FakeRedis.
1 parent 2f7b9c0 commit 047f1ba

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

test/test_mixins/test_keyspace_notifications.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ def wait_for_message(pubsub: PubSub, timeout=0.5, ignore_subscribe_messages=Fals
1313
now = time.time()
1414
return None
1515

16-
def test_keyspace_notifications():
17-
import fakeredis
18-
19-
server = fakeredis.FakeServer()
20-
r = fakeredis.FakeRedis(server=server)
21-
16+
def test_keyspace_notifications(r):
2217
# Enable keyspace notifications in redis
2318
r.config_set('notify-keyspace-events', 'KEA')
2419

2520
p = r.pubsub()
26-
p.psubscribe('__keyspace@0__:*')
27-
p.psubscribe('__keyevent@0__:*')
21+
p.psubscribe('__keyspace@*__:*')
22+
p.psubscribe('__keyevent@*__:*')
2823

2924
msg1 = wait_for_message(p)
3025
msg2 = wait_for_message(p)
@@ -41,8 +36,9 @@ def test_keyspace_notifications():
4136

4237
assert len(msgs) >= 2
4338

44-
keyspace_msg = next((m for m in msgs if m['channel'] == b'__keyspace@0__:foo'), None)
45-
keyevent_msg = next((m for m in msgs if m['channel'] == b'__keyevent@0__:set'), None)
39+
# We are using db=2 based on conftest.py
40+
keyspace_msg = next((m for m in msgs if m['channel'] == b'__keyspace@2__:foo'), None)
41+
keyevent_msg = next((m for m in msgs if m['channel'] == b'__keyevent@2__:set'), None)
4642

4743
assert keyspace_msg is not None
4844
assert keyspace_msg['data'] == b'set'

0 commit comments

Comments
 (0)