test: isolate redis py4 import fallback

This commit is contained in:
dajiaohuang 2026-09-04 14:47:14 +08:00
parent 5eb2f65380
commit 3c35c46f96

View file

@ -543,12 +543,18 @@ def test_valkey_cache_supports_redis_py_4_index_module():
import sys
import types
from redis.commands.search.index_definition import IndexDefinition, IndexType
class IndexDefinition:
def __init__(self, *args, **kwargs):
pass
class IndexType:
pass
legacy = types.ModuleType("redis.commands.search.indexDefinition")
legacy.IndexDefinition = IndexDefinition
legacy.IndexType = IndexType
sys.modules[legacy.__name__] = legacy
original_import = builtins.__import__
def compatibility_import(name, *args, **kwargs):