mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
test: capture the startup warning with caplog instead of patching the logger
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
107b99c733
commit
2f4032a984
1 changed files with 9 additions and 11 deletions
|
|
@ -1076,19 +1076,17 @@ async def test_prometheus_fallback_stats_job_runs_when_the_lock_is_free_or_absen
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_proxy_startup_event_warns_but_does_not_raise_for_docs_example_master_key(monkeypatch):
|
||||
async def test_proxy_startup_event_warns_but_does_not_raise_for_docs_example_master_key(monkeypatch, caplog):
|
||||
monkeypatch.setenv("LITELLM_MASTER_KEY", "sk-1234")
|
||||
|
||||
with patch.object(ps.verbose_proxy_logger, "warning") as mock_warning:
|
||||
try:
|
||||
try:
|
||||
with caplog.at_level(logging.WARNING, logger="LiteLLM Proxy"):
|
||||
async with proxy_startup_event(app=None):
|
||||
pass
|
||||
except ValueError as e:
|
||||
if "sk-1234" in str(e):
|
||||
pytest.fail("proxy_startup_event refused to boot on the docs example key")
|
||||
except Exception:
|
||||
pass
|
||||
except ValueError as e:
|
||||
if "sk-1234" in str(e):
|
||||
pytest.fail("proxy_startup_event refused to boot on the docs example key")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
assert any("sk-1234" in str(call.args[0]) for call in mock_warning.call_args_list), (
|
||||
"startup should log the insecure master key warning"
|
||||
)
|
||||
assert "sk-1234" in caplog.text, "startup should log the insecure master key warning"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue