1313# limitations under the License.
1414
1515import asyncio
16+ from uuid import uuid4
1617
1718import pytest
1819from testing_support .db_settings import valkey_settings
@@ -123,6 +124,9 @@ def test_async_pubsub(client, loop):
123124 messages_received = []
124125 message_received = asyncio .Event ()
125126
127+ channel_1 = f"channel:{ uuid4 ()} "
128+ channel_2 = f"channel:{ uuid4 ()} "
129+
126130 async def reader (pubsub ):
127131 while True :
128132 message = await pubsub .get_message (ignore_subscribe_messages = True )
@@ -140,13 +144,13 @@ async def _publish(client, channel, message):
140144
141145 async def _test_pubsub ():
142146 async with client .pubsub () as pubsub :
143- await pubsub .psubscribe ("channel:*" )
147+ await pubsub .psubscribe (channel_1 , channel_2 )
144148
145149 future = asyncio .create_task (reader (pubsub ))
146150
147- await _publish (client , "channel:1" , "Hello" )
148- await _publish (client , "channel:2" , "World" )
149- await _publish (client , "channel:1" , "NOPE" )
151+ await _publish (client , channel_1 , "Hello" )
152+ await _publish (client , channel_2 , "World" )
153+ await _publish (client , channel_1 , "NOPE" )
150154
151155 await future
152156
0 commit comments