mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-17 00:26:01 +00:00
fix(tests): clear ANTHROPIC_BASE_URL/ANTHROPIC_API_BASE in spend log api_base tests (#21820)
Tests hardcode expected api_base as https://api.anthropic.com/v1/messages but if ANTHROPIC_BASE_URL is set in the environment the recorded api_base changes, causing a mismatch. Clear both env vars via monkeypatch at the start of each test.
This commit is contained in:
@@ -1324,6 +1324,10 @@ class TestSpendLogsPayload:
|
||||
async def test_spend_logs_payload_success_log_with_api_base(self, monkeypatch):
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
|
||||
|
||||
# Clear any env overrides that would change the recorded api_base
|
||||
monkeypatch.delenv("ANTHROPIC_BASE_URL", raising=False)
|
||||
monkeypatch.delenv("ANTHROPIC_API_BASE", raising=False)
|
||||
|
||||
litellm.callbacks = [_ProxyDBLogger(message_logging=False)]
|
||||
# litellm._turn_on_debug()
|
||||
|
||||
@@ -1397,9 +1401,13 @@ class TestSpendLogsPayload:
|
||||
assert False, f"Dictionary mismatch: {differences}"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_spend_logs_payload_success_log_with_router(self):
|
||||
async def test_spend_logs_payload_success_log_with_router(self, monkeypatch):
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
|
||||
|
||||
# Clear any env overrides that would change the recorded api_base
|
||||
monkeypatch.delenv("ANTHROPIC_BASE_URL", raising=False)
|
||||
monkeypatch.delenv("ANTHROPIC_API_BASE", raising=False)
|
||||
|
||||
litellm.callbacks = [_ProxyDBLogger(message_logging=False)]
|
||||
# litellm._turn_on_debug()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user