test(caching): skip the disk round trip when the optional diskcache extra is absent

The default CI test environment does not install litellm[caching], so the
disk parametrization raised ModuleNotFoundError there. importorskip keeps
the coverage wherever the extra is present and skips cleanly otherwise.
This commit is contained in:
eatmoreduck 2026-09-15 15:03:30 +08:00
parent 6fc11546f0
commit b29e0c6c87

View file

@ -41,6 +41,11 @@ def _make_response_with_citations() -> ModelResponse:
@pytest.mark.parametrize("cache_type", ["local", "disk"])
def test_cache_round_trip_preserves_provider_specific_fields(cache_type, tmp_path):
if cache_type == "disk":
# DiskCache is an optional extra (`litellm[caching]`); the default CI
# test environment does not install it, so exercise that path only
# where the dependency is present.
pytest.importorskip("diskcache")
litellm.cache = Cache(type=cache_type, disk_cache_dir=str(tmp_path / "litellm_cache"))
try:
kwargs = {