From b0ac2f2dc35ca433af0c82f3cda770d6981caff4 Mon Sep 17 00:00:00 2001 From: mubashir1osmani Date: Wed, 24 Sep 2025 02:29:30 -0400 Subject: [PATCH] fix flaky test --- tests/pass_through_tests/test_anthropic_passthrough.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/pass_through_tests/test_anthropic_passthrough.py b/tests/pass_through_tests/test_anthropic_passthrough.py index e0549d17fa2..002fb20e9e8 100644 --- a/tests/pass_through_tests/test_anthropic_passthrough.py +++ b/tests/pass_through_tests/test_anthropic_passthrough.py @@ -43,8 +43,9 @@ async def test_anthropic_basic_completion_with_headers(): json.dumps(response_json, indent=4, default=str), ) reported_usage = response_json.get("usage", None) - anthropic_api_input_tokens = reported_usage.get("input_tokens", None) - anthropic_api_output_tokens = reported_usage.get("output_tokens", None) + # fix null checks for reported_usage + anthropic_api_input_tokens = reported_usage.get("input_tokens", None) if reported_usage else None + anthropic_api_output_tokens = reported_usage.get("output_tokens", None) if reported_usage else None litellm_call_id = response_headers.get("x-litellm-call-id") print(f"LiteLLM Call ID: {litellm_call_id}")