mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-29 01:42:19 +00:00
test(proxy): pin known-callbacks precondition in config-file logger tests
test_add_callbacks_from_db_config clears _known_custom_logger_compatible_callbacks without restoring it, and the conftest module snapshot skips underscore attrs, so later tests depend on file order. Assert the precondition via monkeypatch (which auto-restores) in both custom-logger tests.
This commit is contained in:
parent
1592bccf54
commit
94ce3b1d50
1 changed files with 14 additions and 0 deletions
|
|
@ -180,6 +180,13 @@ async def test_config_file_success_callback_registers_custom_logger_instance(mon
|
|||
monkeypatch.setattr(litellm, "_async_success_callback", [])
|
||||
monkeypatch.setattr(litellm, "failure_callback", [])
|
||||
monkeypatch.setattr(litellm, "_async_failure_callback", [])
|
||||
# test_add_callbacks_from_db_config clears _known_custom_logger_compatible_callbacks
|
||||
# without restoring it (and the conftest snapshot skips underscore attrs), so
|
||||
# re-assert the precondition explicitly instead of depending on test order.
|
||||
known_callbacks = list(getattr(litellm, "_known_custom_logger_compatible_callbacks", []))
|
||||
if "langfuse" not in known_callbacks:
|
||||
known_callbacks.append("langfuse")
|
||||
monkeypatch.setattr(litellm, "_known_custom_logger_compatible_callbacks", known_callbacks)
|
||||
# the custom-logger instance path needs env credentials; without them the
|
||||
# config path falls back to the string and this test would not exercise
|
||||
# the instance registration
|
||||
|
|
@ -236,6 +243,13 @@ async def test_config_file_callback_falls_back_to_string_when_init_fails(monkeyp
|
|||
monkeypatch.setattr(litellm, "_async_success_callback", [])
|
||||
monkeypatch.setattr(litellm, "failure_callback", [])
|
||||
monkeypatch.setattr(litellm, "_async_failure_callback", [])
|
||||
# same precondition as the sibling instance test: langfuse must be a known
|
||||
# custom-logger name, otherwise the config path skips the helper entirely
|
||||
# and this test would not exercise the fallback branch
|
||||
known_callbacks = list(getattr(litellm, "_known_custom_logger_compatible_callbacks", []))
|
||||
if "langfuse" not in known_callbacks:
|
||||
known_callbacks.append("langfuse")
|
||||
monkeypatch.setattr(litellm, "_known_custom_logger_compatible_callbacks", known_callbacks)
|
||||
monkeypatch.setattr(
|
||||
"litellm.litellm_core_utils.litellm_logging._init_custom_logger_compatible_class",
|
||||
lambda callback, internal_usage_cache=None, llm_router=None: None,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue