Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

727 B
Raw Blame
from typing import Final

import pytest

import litellm
from litellm.caching.caching import Cache
from litellm.rust_bridge.host.cache import configured_cache
from litellm.types.caching import LiteLLMCacheType


def test_configured_cache_preserves_identity_and_observes_runtime_replacement(monkeypatch: pytest.MonkeyPatch) -> None:
    initial: Final = Cache(type=LiteLLMCacheType.LOCAL)
    replacement: Final = Cache(type=LiteLLMCacheType.LOCAL)
    monkeypatch.setattr(litellm, "cache", initial)
    assert configured_cache() is initial

    monkeypatch.setattr(litellm, "cache", replacement)
    assert configured_cache() is replacement

    monkeypatch.setattr(litellm, "cache", None)
    assert configured_cache() is None