"""Stub the redis package so materializer.py can be imported without it installed. materialize_from_api() (exercised by these tests) never touches redis at all — only materialize() (the legacy direct-Redis path) does — but the module-level `import redis` runs regardless, so a stub must be in place before import. """ from __future__ import annotations import sys import types def _make_redis_stub() -> types.ModuleType: mod = types.ModuleType("redis") class _ConnectionError(Exception): pass class _ResponseError(Exception): pass exceptions_mod = types.ModuleType("redis.exceptions") exceptions_mod.ConnectionError = _ConnectionError exceptions_mod.ResponseError = _ResponseError mod.exceptions = exceptions_mod mod.Redis = object return mod if "redis" not in sys.modules: stub = _make_redis_stub() sys.modules["redis"] = stub sys.modules["redis.exceptions"] = stub.exceptions