From 23f5df05f2b55f88aa39b6e58c6d57b3b46a3d95 Mon Sep 17 00:00:00 2001 From: kerry Date: Sat, 19 Sep 2026 21:03:51 +0000 Subject: [PATCH] test(integration): require a zero cost header to read zero when the case bills nothing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- tests/integration/cost_calculation/test_cost_tracking.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/cost_calculation/test_cost_tracking.py b/tests/integration/cost_calculation/test_cost_tracking.py index 6c1ac166196..3822b5cb3c6 100644 --- a/tests/integration/cost_calculation/test_cost_tracking.py +++ b/tests/integration/cost_calculation/test_cost_tracking.py @@ -92,7 +92,11 @@ def test_case_bills_expected_cost(gateway: Gateway, case: CostTrackingTestCase) assert isinstance(expected, ExactExpected) if case.response.content_type == "application/json": header: Final = cast(str | None, response.headers.get("x-litellm-response-cost")) - assert expected.spend == 0 or (header is not None and approx_equal(float(header), expected.spend)), ( + assert ( + (header is None or approx_equal(float(header), 0.0)) + if expected.spend == 0 + else (header is not None and approx_equal(float(header), expected.spend)) + ), ( f"{case.name}: x-litellm-response-cost {header} != expected {expected.spend}" ) assert row.spend is not None and approx_equal(row.spend, expected.spend), (