mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
tests(vcr): force pure-httpx transport when VCR is active
litellm's default LiteLLMAiohttpTransport routes requests through aiohttp, which sits below httpx and is invisible to vcrpy's httpx-stub interception. Under vcrpy + aiohttp, requests reach the real network but responses come back through the stubbed httpx transport as empty 200s, surfacing as 'Unable to get json response - Expecting value: line 1 column 1 (char 0)' in providers like Anthropic, Gemini, and any other path that exercises the aiohttp transport. Disabling the aiohttp transport when the VCR persister is registered forces all calls through pure httpx, which vcrpy can record and replay correctly.
This commit is contained in:
parent
68db1c5e9e
commit
265a94cd60
2 changed files with 10 additions and 0 deletions
|
|
@ -97,6 +97,11 @@ def pytest_recording_configure(config, vcr):
|
|||
if _vcr_disabled():
|
||||
return
|
||||
vcr.register_persister(make_redis_persister())
|
||||
# vcrpy patches httpx's transport; litellm's default AiohttpTransport
|
||||
# routes around httpx and produces empty responses under the patched
|
||||
# transport. Force pure-httpx transport so vcrpy can record/replay.
|
||||
litellm.disable_aiohttp_transport = True
|
||||
os.environ["DISABLE_AIOHTTP_TRANSPORT"] = "True"
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@ def pytest_recording_configure(config, vcr):
|
|||
if _vcr_disabled():
|
||||
return
|
||||
vcr.register_persister(make_redis_persister())
|
||||
# vcrpy patches httpx's transport; litellm's default AiohttpTransport
|
||||
# routes around httpx and produces empty responses under the patched
|
||||
# transport. Force pure-httpx transport so vcrpy can record/replay.
|
||||
litellm.disable_aiohttp_transport = True
|
||||
os.environ["DISABLE_AIOHTTP_TRANSPORT"] = "True"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue