@@ -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
@@ -1217,6 +1216,32 @@ async def test_sinter(self, redis_client: TRedisClient):
12171216 await redis_client .sinter ([key2 ])
12181217 assert "Operation against a key holding the wrong kind of value" in str (e )
12191218
1219+ @pytest .mark .parametrize ("cluster_mode" , [True , False ])
1220+ @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
1221+ async def test_sdiff (self , redis_client : TRedisClient ):
1222+ key1 = f"{{testKey}}:1-{ get_random_string (10 )} "
1223+ key2 = f"{{testKey}}:2-{ get_random_string (10 )} "
1224+ string_key = f"{{testKey}}:4-{ get_random_string (10 )} "
1225+ non_existing_key = f"{{testKey}}:5-{ get_random_string (10 )} "
1226+
1227+ assert await redis_client .sadd (key1 , ["a" , "b" , "c" ]) == 3
1228+ assert await redis_client .sadd (key2 , ["c" , "d" , "e" ]) == 3
1229+
1230+ assert await redis_client .sdiff ([key1 , key2 ]) == {"a" , "b" }
1231+ assert await redis_client .sdiff ([key2 , key1 ]) == {"d" , "e" }
1232+
1233+ assert await redis_client .sdiff ([key1 , non_existing_key ]) == {"a" , "b" , "c" }
1234+ assert await redis_client .sdiff ([non_existing_key , key1 ]) == set ()
1235+
1236+ # invalid argument - key list must not be empty
1237+ with pytest .raises (RequestError ):
1238+ await redis_client .sdiff ([])
1239+
1240+ # key exists, but it is not a set
1241+ assert await redis_client .set (string_key , "value" ) == OK
1242+ with pytest .raises (RequestError ):
1243+ await redis_client .sdiff ([string_key ])
1244+
12201245 @pytest .mark .parametrize ("cluster_mode" , [True , False ])
12211246 @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
12221247 async def test_ltrim (self , redis_client : TRedisClient ):
@@ -3157,6 +3182,7 @@ async def test_multi_key_command_returns_cross_slot_error(
31573182 redis_client .smove ("abc" , "def" , "_" ),
31583183 redis_client .sunionstore ("abc" , ["zxy" , "lkn" ]),
31593184 redis_client .sinter (["abc" , "zxy" , "lkn" ]),
3185+ redis_client .sdiff (["abc" , "zxy" , "lkn" ]),
31603186 ]
31613187
31623188 if not check_if_server_version_lt (redis_client , "7.0.0" ):
0 commit comments