Files
litellm/tests/test_litellm/proxy/test_max_budget_env_var.py
T
Krrish DholakiaandClaude Opus 4.6 509d2e9ac3 Fix PR review issues: gpt-4-0314 prompt caching, case-insensitive data URL check, test I/O mocking
- Remove incorrect supports_prompt_caching from gpt-4-0314 (predates the feature)
- Make data-URL detection case-insensitive in Gemini tool call result conversion
- Mock show_banner/generate_feedback_box in max_budget tests to prevent real I/O

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 11:30:29 -07:00

50 lines
1.5 KiB
Python

"""
Test that max_budget from environment variable (string) is correctly
converted to float.
GitHub Issue: #23843
"""
from unittest.mock import patch
import pytest
import litellm
@pytest.mark.asyncio
async def test_max_budget_string_converted_to_float():
"""
When max_budget is set via os.environ/MAX_BUDGET, it arrives as a
string. initialize() should convert it to float so the comparison
`litellm.max_budget > 0` doesn't raise TypeError.
"""
with patch("litellm.proxy.common_utils.banner.show_banner"), patch(
"litellm.proxy.proxy_server.generate_feedback_box"
):
from litellm.proxy.proxy_server import initialize
original = litellm.max_budget
try:
await initialize(max_budget="100.5")
assert isinstance(litellm.max_budget, float)
assert litellm.max_budget == 100.5
finally:
litellm.max_budget = original
@pytest.mark.asyncio
async def test_max_budget_float_stays_float():
"""max_budget as float should still work."""
with patch("litellm.proxy.common_utils.banner.show_banner"), patch(
"litellm.proxy.proxy_server.generate_feedback_box"
):
from litellm.proxy.proxy_server import initialize
original = litellm.max_budget
try:
await initialize(max_budget=200.0)
assert isinstance(litellm.max_budget, float)
assert litellm.max_budget == 200.0
finally:
litellm.max_budget = original