From 198b31b9d565bb688623050868341d551dff5dcf Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 09:02:00 -0700 Subject: [PATCH] test(router): assert the context-window error reports the deployment's own count --- tests/code_coverage_tests/router_code_coverage.py | 2 +- tests/unit/test_router/test_router.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/code_coverage_tests/router_code_coverage.py b/tests/code_coverage_tests/router_code_coverage.py index 35ea66763a9..6fcf954cc1a 100644 --- a/tests/code_coverage_tests/router_code_coverage.py +++ b/tests/code_coverage_tests/router_code_coverage.py @@ -185,7 +185,7 @@ ignored_function_names = [ "_pre_call_check_token_count", # Run by _pre_call_check_token_counts, tested through the per-deployment pre-call check tests in test_router.py "_pre_call_check_token_counts", # Run by _pre_call_checks and _acount_pre_call_check_tokens, tested through the pre-call check tests in test_router.py "_resolve_pre_call_check_token_counts", # Run by _pre_call_checks, tested through the precounted and inline pre-call check tests in test_router.py - "_context_window_exceeded_line", # Builds the ContextWindowExceededError text, tested through the Got= assertions in test_router.py + "_context_window_exceeded_line", # Builds the ContextWindowExceededError text, tested through the stand-in margin refusal test in test_router.py ] diff --git a/tests/unit/test_router/test_router.py b/tests/unit/test_router/test_router.py index 9d6d1d3db36..6e280cca81f 100644 --- a/tests/unit/test_router/test_router.py +++ b/tests/unit/test_router/test_router.py @@ -30351,7 +30351,9 @@ def test_pre_call_checks_refuses_a_stand_in_count_past_the_margin(): tokens: Final = _stand_in_tokens(_RUSSIAN_PROMPT) largest_window_past_margin: Final = (tokens - 1) // STAND_IN_OVERCOUNT_MARGIN - with pytest.raises(litellm.ContextWindowExceededError): + with pytest.raises( + litellm.ContextWindowExceededError, match=f"Max Input Tokens={largest_window_past_margin}, Got={tokens}" + ): _kept_ids(_single_deployment("openai/my-fake-model", largest_window_past_margin), _RUSSIAN_PROMPT)