@@ -1102,7 +1102,6 @@ async def test_smove(self, redis_client: TRedisClient):
11021102 key1 = f"{{testKey}}:1-{ get_random_string (10 )} "
11031103 key2 = f"{{testKey}}:2-{ get_random_string (10 )} "
11041104 key3 = f"{{testKey}}:3-{ get_random_string (10 )} "
1105- key4 = f"{{testKey}}:4-{ get_random_string (10 )} "
11061105 string_key = f"{{testKey}}:4-{ get_random_string (10 )} "
11071106 non_existing_key = f"{{testKey}}:5-{ get_random_string (10 )} "
11081107
@@ -1190,6 +1189,32 @@ async def test_sunionstore(self, redis_client: TRedisClient):
11901189 "g" ,
11911190 }
11921191
1192+ @pytest .mark .parametrize ("cluster_mode" , [True , False ])
1193+ @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
1194+ async def test_sdiff (self , redis_client : TRedisClient ):
1195+ key1 = f"{{testKey}}:1-{ get_random_string (10 )} "
1196+ key2 = f"{{testKey}}:2-{ get_random_string (10 )} "
1197+ string_key = f"{{testKey}}:4-{ get_random_string (10 )} "
1198+ non_existing_key = f"{{testKey}}:5-{ get_random_string (10 )} "
1199+
1200+ assert await redis_client .sadd (key1 , ["a" , "b" , "c" ]) == 3
1201+ assert await redis_client .sadd (key2 , ["c" , "d" , "e" ]) == 3
1202+
1203+ assert await redis_client .sdiff ([key1 , key2 ]) == {"a" , "b" }
1204+ assert await redis_client .sdiff ([key2 , key1 ]) == {"d" , "e" }
1205+
1206+ assert await redis_client .sdiff ([key1 , non_existing_key ]) == {"a" , "b" , "c" }
1207+ assert await redis_client .sdiff ([non_existing_key , key1 ]) == set ()
1208+
1209+ # invalid argument - key list must not be empty
1210+ with pytest .raises (RequestError ):
1211+ await redis_client .sdiff ([])
1212+
1213+ # key exists, but it is not a set
1214+ assert await redis_client .set (string_key , "value" ) == OK
1215+ with pytest .raises (RequestError ):
1216+ await redis_client .sdiff ([string_key ])
1217+
11931218 @pytest .mark .parametrize ("cluster_mode" , [True , False ])
11941219 @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
11951220 async def test_ltrim (self , redis_client : TRedisClient ):
@@ -3129,6 +3154,7 @@ async def test_multi_key_command_returns_cross_slot_error(
31293154 redis_client .bzpopmax (["abc" , "zxy" , "lkn" ], 0.5 ),
31303155 redis_client .smove ("abc" , "def" , "_" ),
31313156 redis_client .sunionstore ("abc" , ["zxy" , "lkn" ]),
3157+ redis_client .sdiff (["abc" , "zxy" , "lkn" ]),
31323158 ]
31333159
31343160 if not check_if_server_version_lt (redis_client , "7.0.0" ):
0 commit comments