@@ -215,18 +215,18 @@ def test_optimize_threshold_cache_default(redis_url):
215215 assert cache .distance_threshold > null_threshold
216216
217217
218- def test_optimize_threshold_cache_precision (redis_url ):
218+ def test_optimize_threshold_cache_precision (client , redis_url ):
219+ redis_version = client .info ()["redis_version" ]
220+ if not compare_versions (redis_version , "7.0.0" ):
221+ pytest .skip ("Not using a late enough version of Redis" )
222+
219223 null_threshold = 0.0
220224 cache = SemanticCache (
221225 name = "test_optimize_threshold_cache" ,
222226 redis_url = redis_url ,
223227 distance_threshold = null_threshold ,
224228 )
225229
226- redis_version = cache ._index .client .info ()["redis_version" ]
227- if not compare_versions (redis_version , "7.0.0" ):
228- pytest .skip ("Not using a late enough version of Redis" )
229-
230230 paris_key = cache .store (prompt = "what is the capital of france?" , response = "paris" )
231231 rabat_key = cache .store (prompt = "what is the capital of morocco?" , response = "rabat" )
232232
@@ -243,18 +243,18 @@ def test_optimize_threshold_cache_precision(redis_url):
243243 assert cache .distance_threshold > null_threshold
244244
245245
246- def test_optimize_threshold_cache_recall (redis_url ):
246+ def test_optimize_threshold_cache_recall (client , redis_url ):
247+ redis_version = client .info ()["redis_version" ]
248+ if not compare_versions (redis_version , "7.0.0" ):
249+ pytest .skip ("Not using a late enough version of Redis" )
250+
247251 null_threshold = 0.0
248252 cache = SemanticCache (
249253 name = "test_optimize_threshold_cache" ,
250254 redis_url = redis_url ,
251255 distance_threshold = null_threshold ,
252256 )
253257
254- redis_version = cache ._index .client .info ()["redis_version" ]
255- if not compare_versions (redis_version , "7.0.0" ):
256- pytest .skip ("Not using a late enough version of Redis" )
257-
258258 paris_key = cache .store (prompt = "what is the capital of france?" , response = "paris" )
259259 rabat_key = cache .store (prompt = "what is the capital of morocco?" , response = "rabat" )
260260
0 commit comments