litellm/tests/llm_translation/test_prompt_caching.py
Cursor Agent 93300019bd
test(vcr): drop dead 'from respx import MockRouter' imports
These seven test files were on _RESPX_CONFLICTING_FILES, which made the
auto-marker skip them entirely. Inspecting the source shows the only
respx artifact is a top-level 'from respx import MockRouter' that no
test ever uses - no @pytest.mark.respx, no respx_mock fixture, no
respx.mock context manager. The import is dead code left over from a
previous mocking pattern.

Now that apply_vcr_auto_marker_to_items detects respx per-item via the
marker / fixture chain (b637d9f64a), the file-level skip is no longer
needed for these files - they were the reason the OpenAI tests
(test_o3_reasoning_effort, test_streaming_response[o1/o3-mini],
TestOpenAIO1::test_streaming, TestOpenAIChatCompletion::test_web_search,
TestOpenAIO3::test_web_search, etc.) ran live every CI build despite
the cassette cache being healthy.

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-05-13 00:32:03 +00:00

33 lines
908 B
Python

import json
import os
import sys
from datetime import datetime
from unittest.mock import AsyncMock
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
import httpx
import pytest
import litellm
from litellm import Choices, Message, ModelResponse
from litellm.types.utils import PromptTokensDetails
@pytest.mark.asyncio
async def test_prompt_caching():
"""
Tests that:
- prompt_tokens_details is correctly handled and returned as PromptTokensDetails type
"""
response1 = await litellm.acompletion(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "hi"}],
)
print("response1", response1)
print("response1.usage", response1.usage)
print("type of prompt_tokens_details", type(response1.usage.prompt_tokens_details))
assert isinstance(response1.usage.prompt_tokens_details, PromptTokensDetails)