style: apply Black formatting to test file

This commit is contained in:
Kevin(이주오) 2026-03-17 11:51:40 +09:00
parent e61de3e048
commit 0601745deb

View file

@ -124,12 +124,12 @@ def test_custom_pricing_skips_provider_response_cost():
)
# Must use custom pricing, NOT provider response cost
assert result != provider_usd_cost, (
f"Should not use provider response cost ({provider_usd_cost})"
)
assert result == pytest.approx(expected_custom_cost), (
f"Got {result}, expected {expected_custom_cost} from custom pricing"
)
assert (
result != provider_usd_cost
), f"Should not use provider response cost ({provider_usd_cost})"
assert result == pytest.approx(
expected_custom_cost
), f"Got {result}, expected {expected_custom_cost} from custom pricing"
def test_provider_response_cost_used_when_no_custom_pricing():
@ -140,9 +140,7 @@ def test_provider_response_cost_used_when_no_custom_pricing():
class MockResponse(BaseModel):
_hidden_params = {
"additional_headers": {
"llm_provider-x-litellm-response-cost": 0.0000024
}
"additional_headers": {"llm_provider-x-litellm-response-cost": 0.0000024}
}
result = response_cost_calculator(
@ -156,9 +154,7 @@ def test_provider_response_cost_used_when_no_custom_pricing():
custom_pricing=False,
)
assert result == 0.0000024, (
f"Should use provider response cost, got {result}"
)
assert result == 0.0000024, f"Should use provider response cost, got {result}"
def test_custom_pricing_without_provider_response_cost():
@ -211,9 +207,9 @@ def test_custom_pricing_without_provider_response_cost():
expected_cost = (
prompt_tokens * custom_input_cost + completion_tokens * custom_output_cost
)
assert result == pytest.approx(expected_cost), (
f"Got {result}, expected {expected_cost} from custom pricing"
)
assert result == pytest.approx(
expected_cost
), f"Got {result}, expected {expected_cost} from custom pricing"
def test_cost_calculator_with_usage(monkeypatch):
@ -272,6 +268,7 @@ def test_cost_calculator_with_usage(monkeypatch):
# Invalidate caches after modifying litellm.model_cost
from litellm.utils import _invalidate_model_cost_lowercase_map
_invalidate_model_cost_lowercase_map()
result = response_cost_calculator(
@ -677,9 +674,7 @@ def test_azure_audio_output_cost_calculation():
model_info = litellm.get_model_info("azure/gpt-audio-2025-08-28")
# Calculate expected cost
expected_input_cost = (
model_info["input_cost_per_token"] * 17 # text tokens
)
expected_input_cost = model_info["input_cost_per_token"] * 17 # text tokens
expected_output_cost = (
model_info["output_cost_per_token"] * 110 # text tokens
+ model_info["output_cost_per_audio_token"] * 482 # audio tokens
@ -691,14 +686,14 @@ def test_azure_audio_output_cost_calculation():
wrong_total_cost = expected_input_cost + wrong_output_cost
# Verify audio tokens are NOT charged at text rate (the bug)
assert abs(cost - wrong_total_cost) > 0.001, (
"Bug: Audio tokens are being charged at text token rate"
)
assert (
abs(cost - wrong_total_cost) > 0.001
), "Bug: Audio tokens are being charged at text token rate"
# Verify cost matches
assert abs(cost - expected_total_cost) < 0.0000001, (
f"Expected cost {expected_total_cost}, got {cost}"
)
assert (
abs(cost - expected_total_cost) < 0.0000001
), f"Expected cost {expected_total_cost}, got {cost}"
def test_default_image_cost_calculator(monkeypatch):
@ -1205,12 +1200,12 @@ def test_azure_ai_cache_cost_calculation():
print(f"Output cost: {output_cost}, Expected: {expected_output_cost}")
print(f"Total cost: {total_cost}")
assert abs(input_cost - expected_input_cost) < 1e-10, (
f"Input cost mismatch: got {input_cost}, expected {expected_input_cost}"
)
assert abs(output_cost - expected_output_cost) < 1e-10, (
f"Output cost mismatch: got {output_cost}, expected {expected_output_cost}"
)
assert (
abs(input_cost - expected_input_cost) < 1e-10
), f"Input cost mismatch: got {input_cost}, expected {expected_input_cost}"
assert (
abs(output_cost - expected_output_cost) < 1e-10
), f"Output cost mismatch: got {output_cost}, expected {expected_output_cost}"
def test_cost_discount_vertex_ai():
@ -2078,7 +2073,9 @@ def test_gemini_implicit_caching_cost_calculation():
f"Cached tokens may not be using reduced pricing."
)
print("✅ Issue #16341 fix verified: Gemini implicit caching cost calculated correctly")
print(
"✅ Issue #16341 fix verified: Gemini implicit caching cost calculated correctly"
)
def test_additional_costs_only_for_azure_ai():