mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
tests(vcr): drop redundant comments and docstrings
Some checks failed
Unit Tests: Caching (Redis) / caching-redis (push) Has been cancelled
Unit Tests: Proxy DB Operations / assert-shard-coverage (push) Has been cancelled
Unit Tests: Security / security (push) Has been cancelled
Unit Tests: Proxy DB Operations / auth-checks (push) Has been cancelled
Unit Tests: Proxy DB Operations / budgets (push) Has been cancelled
Unit Tests: Proxy DB Operations / custom-logging (push) Has been cancelled
Unit Tests: Proxy DB Operations / db-and-spend (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-runtime (push) Has been cancelled
Unit Tests: Proxy DB Operations / endpoints-and-responses (push) Has been cancelled
Unit Tests: Proxy DB Operations / guardrails-hooks (push) Has been cancelled
Unit Tests: Proxy DB Operations / jwt-and-keys (push) Has been cancelled
Unit Tests: Proxy DB Operations / key-generation (push) Has been cancelled
Unit Tests: Proxy DB Operations / logging-misc (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-server-core (push) Has been cancelled
Unit Tests: Proxy DB Operations / schema-migration (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-utils (push) Has been cancelled
Some checks failed
Unit Tests: Caching (Redis) / caching-redis (push) Has been cancelled
Unit Tests: Proxy DB Operations / assert-shard-coverage (push) Has been cancelled
Unit Tests: Security / security (push) Has been cancelled
Unit Tests: Proxy DB Operations / auth-checks (push) Has been cancelled
Unit Tests: Proxy DB Operations / budgets (push) Has been cancelled
Unit Tests: Proxy DB Operations / custom-logging (push) Has been cancelled
Unit Tests: Proxy DB Operations / db-and-spend (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-runtime (push) Has been cancelled
Unit Tests: Proxy DB Operations / endpoints-and-responses (push) Has been cancelled
Unit Tests: Proxy DB Operations / guardrails-hooks (push) Has been cancelled
Unit Tests: Proxy DB Operations / jwt-and-keys (push) Has been cancelled
Unit Tests: Proxy DB Operations / key-generation (push) Has been cancelled
Unit Tests: Proxy DB Operations / logging-misc (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-server-core (push) Has been cancelled
Unit Tests: Proxy DB Operations / schema-migration (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-utils (push) Has been cancelled
This commit is contained in:
parent
687ff32616
commit
67287460e5
4 changed files with 5 additions and 38 deletions
|
|
@ -91,26 +91,13 @@ _PATCHED_AIOHTTP_RECORD = False
|
|||
|
||||
|
||||
def patch_vcrpy_aiohttp_record_path() -> None:
|
||||
"""Make vcrpy's aiohttp record path leave the response body re-readable.
|
||||
|
||||
vcrpy.stubs.aiohttp_stubs.record_response calls ``await response.read()``
|
||||
to capture the body for the cassette, which drains aiohttp's StreamReader.
|
||||
Downstream consumers of the same ClientResponse (e.g.
|
||||
``litellm.llms.custom_httpx.aiohttp_transport.AiohttpResponseStream``,
|
||||
which iterates ``response.content.iter_chunked``) then see an empty body
|
||||
and surface as ``Expecting value: line 1 column 1 (char 0)`` JSON errors.
|
||||
|
||||
Re-feed the captured bytes back into the StreamReader via ``unread_data``
|
||||
so the body remains available to whoever holds the ClientResponse next.
|
||||
Idempotent; safe to call from multiple conftests.
|
||||
"""
|
||||
"""Re-feed the response body into aiohttp's StreamReader after vcrpy's
|
||||
record_response drains it, so downstream consumers (e.g.
|
||||
LiteLLMAiohttpTransport.AiohttpResponseStream) can still read it."""
|
||||
global _PATCHED_AIOHTTP_RECORD
|
||||
if _PATCHED_AIOHTTP_RECORD:
|
||||
return
|
||||
try:
|
||||
import vcr.stubs.aiohttp_stubs as _aiohttp_stubs
|
||||
except ImportError: # pragma: no cover - aiohttp not installed in env
|
||||
return
|
||||
import vcr.stubs.aiohttp_stubs as _aiohttp_stubs
|
||||
|
||||
_orig_record_response = _aiohttp_stubs.record_response
|
||||
|
||||
|
|
@ -118,13 +105,7 @@ def patch_vcrpy_aiohttp_record_path() -> None:
|
|||
await _orig_record_response(cassette, vcr_request, response)
|
||||
body = getattr(response, "_body", None) or b""
|
||||
if body:
|
||||
try:
|
||||
response.content.unread_data(body)
|
||||
except Exception:
|
||||
# If aiohttp removes unread_data in a future release we want
|
||||
# the test to fail loudly via the original empty-body
|
||||
# symptom rather than mask the regression here.
|
||||
pass
|
||||
response.content.unread_data(body)
|
||||
|
||||
_aiohttp_stubs.record_response = _record_response_preserving_body
|
||||
_PATCHED_AIOHTTP_RECORD = True
|
||||
|
|
|
|||
|
|
@ -98,9 +98,6 @@ def pytest_recording_configure(config, vcr):
|
|||
if _vcr_disabled():
|
||||
return
|
||||
vcr.register_persister(make_redis_persister())
|
||||
# vcrpy's aiohttp record path drains the response stream via
|
||||
# ``await response.read()``; without the patch, downstream consumers
|
||||
# (litellm's AiohttpResponseStream) see an empty body on first record.
|
||||
patch_vcrpy_aiohttp_record_path()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -122,9 +122,6 @@ def pytest_recording_configure(config, vcr):
|
|||
if _vcr_disabled():
|
||||
return
|
||||
vcr.register_persister(make_redis_persister())
|
||||
# vcrpy's aiohttp record path drains the response stream via
|
||||
# ``await response.read()``; without the patch, downstream consumers
|
||||
# (litellm's AiohttpResponseStream) see an empty body on first record.
|
||||
patch_vcrpy_aiohttp_record_path()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1888,13 +1888,6 @@ def test_metadata_filter_applies_to_azure_anthropic():
|
|||
|
||||
|
||||
def test_anthropic_basic_completion_replay():
|
||||
"""Smoke-test the Anthropic completion pipeline end-to-end via VCR.
|
||||
|
||||
Asserts on response shape rather than specific bytes, so the test is
|
||||
valid both on a fresh CI Redis (records on first run) and on a hot
|
||||
cache (replays). Drift in the *shape* of Anthropic's response surfaces
|
||||
here; drift in the exact text/token counts is expected and ignored.
|
||||
"""
|
||||
response = litellm.completion(
|
||||
model="anthropic/claude-sonnet-4-5-20250929",
|
||||
messages=[{"role": "user", "content": "Hello!"}],
|
||||
|
|
@ -1909,7 +1902,6 @@ def test_anthropic_basic_completion_replay():
|
|||
|
||||
|
||||
def test_anthropic_streaming_completion_replay():
|
||||
"""Same as above for the streaming path; asserts on shape, not bytes."""
|
||||
stream = litellm.completion(
|
||||
model="anthropic/claude-sonnet-4-5-20250929",
|
||||
messages=[{"role": "user", "content": "Hello!"}],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue