Refactoring

This commit is contained in:
Serhii Charykov 2022-04-27 20:01:17 +03:00
parent 56f1d35de9
commit 0ae8ef882e

View file

@ -42,13 +42,13 @@ def cleanup_keys(request):
from redis_om.connections import get_redis_connection as get_sync_redis from redis_om.connections import get_redis_connection as get_sync_redis
# Increment for every pytest-xdist worker # Increment for every pytest-xdist worker
redis = get_sync_redis() conn = get_sync_redis()
once_key = f"{TEST_PREFIX}:cleanup_keys" once_key = f"{TEST_PREFIX}:cleanup_keys"
redis.incr(once_key) conn.incr(once_key)
yield yield
# Delete keys only once # Delete keys only once
if redis.decr(once_key) == 0: if conn.decr(once_key) == 0:
_delete_test_keys(TEST_PREFIX, redis) _delete_test_keys(TEST_PREFIX, conn)
redis.delete(once_key) conn.delete(once_key)