mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
test: address review notes on the chronic-test repairs
Drop the two new docstrings, annotate the new locals Final, and replace the mutable call recorder with a rebuild stub that fails the test if it is ever reached.
This commit is contained in:
parent
dbf8fe0f4e
commit
a5a78670d0
3 changed files with 8 additions and 15 deletions
|
|
@ -74,7 +74,6 @@ def _rebuild(repo_root: Path) -> tuple[bool, str]:
|
|||
|
||||
|
||||
def trace_bridge_error() -> str | None:
|
||||
"""Why the installed bridge cannot serve trace parity, or None when it can. Never rebuilds."""
|
||||
bridge: Final = get_native_bridge()
|
||||
if bridge is None:
|
||||
return "native Rust bridge is not importable"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import asyncio
|
|||
import aiohttp
|
||||
import os
|
||||
import dotenv
|
||||
from typing import Final
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
|
@ -487,9 +488,6 @@ async def test_get_personal_models_for_user():
|
|||
async def test_model_group_info_e2e():
|
||||
"""
|
||||
Test /model/group/info endpoint
|
||||
|
||||
The proxy config declares a wildcard "anthropic/*" deployment, and the endpoint resolves
|
||||
wildcards into the concrete models they cover, so the raw pattern is never returned.
|
||||
"""
|
||||
async with aiohttp.ClientSession() as session:
|
||||
models = await get_models(session=session, key="sk-1234")
|
||||
|
|
@ -498,7 +496,7 @@ async def test_model_group_info_e2e():
|
|||
model_group_info = await get_model_group_info(session=session, key="sk-1234")
|
||||
print(model_group_info)
|
||||
|
||||
model_groups = [m["model_group"] for m in model_group_info["data"]]
|
||||
model_groups: Final = [m["model_group"] for m in model_group_info["data"]]
|
||||
|
||||
assert "anthropic/*" not in model_groups, (
|
||||
f"Expected 'anthropic/*' to be expanded, but it was returned verbatim: {model_groups}"
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ def test_should_leave_functions_without_mapping_contracts_unimplemented() -> Non
|
|||
def test_should_report_a_bridge_that_cannot_be_imported() -> None:
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
patch.setattr(native_build, "get_native_bridge", lambda: None)
|
||||
message = native_build.trace_bridge_error()
|
||||
message: Final = native_build.trace_bridge_error()
|
||||
|
||||
assert message is not None
|
||||
assert "not importable" in message
|
||||
|
|
@ -133,7 +133,7 @@ def test_should_report_a_bridge_that_cannot_be_imported() -> None:
|
|||
def test_should_report_a_bridge_built_without_the_trace_feature() -> None:
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
patch.setattr(native_build, "get_native_bridge", lambda: SimpleNamespace(_trace=None))
|
||||
message = native_build.trace_bridge_error()
|
||||
message: Final = native_build.trace_bridge_error()
|
||||
|
||||
assert message is not None
|
||||
assert native_build.BRIDGE_FEATURE in message
|
||||
|
|
@ -147,18 +147,14 @@ def test_should_accept_a_bridge_built_with_the_trace_feature() -> None:
|
|||
|
||||
|
||||
def test_should_not_rebuild_the_bridge_while_reporting_its_state() -> None:
|
||||
rebuilds: list[object] = []
|
||||
|
||||
def fake_rebuild(repo_root: object) -> tuple[bool, str]:
|
||||
rebuilds.append(repo_root)
|
||||
return True, ""
|
||||
def forbidden_rebuild(repo_root: object) -> tuple[bool, str]:
|
||||
raise AssertionError("trace_bridge_error must not rebuild the native bridge")
|
||||
|
||||
with pytest.MonkeyPatch.context() as patch:
|
||||
patch.setattr(native_build, "_rebuild", fake_rebuild)
|
||||
patch.setattr(native_build, "_rebuild", forbidden_rebuild)
|
||||
patch.setattr(native_build, "get_native_bridge", lambda: None)
|
||||
native_build.trace_bridge_error()
|
||||
|
||||
assert rebuilds == []
|
||||
assert native_build.trace_bridge_error() is not None
|
||||
|
||||
|
||||
def test_should_derive_ocr_mapping_status_from_live_tests() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue