Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-quality-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"limit": 1078
},
"TQ004": {
"limit": 768
"limit": 506
},
"TQ005": {
"limit": 2832
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ def test_multiple_tool_calls_in_single_choice():
print("✓ Multiple tool calls are correctly grouped in a single choice")


def test_map_reasoning_effort_adds_summary_detailed():
def test_map_reasoning_effort_adds_summary_detailed(monkeypatch):
"""
Test that _map_reasoning_effort behavior with reasoning_auto_summary flag.

Expand Down Expand Up @@ -1571,7 +1571,7 @@ def test_map_reasoning_effort_adds_summary_detailed():

# Test 3: With env var enabled (flag disabled) - summary IS added
litellm.reasoning_auto_summary = False
os.environ["LITELLM_REASONING_AUTO_SUMMARY"] = "true"
monkeypatch.setenv("LITELLM_REASONING_AUTO_SUMMARY", "true")

result = handler._map_reasoning_effort("high")
assert (
Expand Down Expand Up @@ -1603,7 +1603,7 @@ def test_map_reasoning_effort_adds_summary_detailed():
# Restore original values
litellm.reasoning_auto_summary = original_flag
if original_env is not None:
os.environ["LITELLM_REASONING_AUTO_SUMMARY"] = original_env
monkeypatch.setenv("LITELLM_REASONING_AUTO_SUMMARY", original_env)
elif "LITELLM_REASONING_AUTO_SUMMARY" in os.environ:
del os.environ["LITELLM_REASONING_AUTO_SUMMARY"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ def test_transform_with_none_optional_params(self):
assert data["expires_after"] is None
assert data["file_ids"] is None

def test_container_create_response_includes_cost(self):
def test_container_create_response_includes_cost(self, monkeypatch):
"""Test that container create response includes code interpreter cost calculation."""
# Force use of local model cost map for CI/CD consistency
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
litellm.model_cost = litellm.get_model_cost_map(url="")

from litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def test_send_email_success(mock_env_vars):


@pytest.mark.asyncio
async def test_send_email_missing_api_key():
async def test_send_email_missing_api_key(monkeypatch):
# Remove the API key from environment before initializing logger
original_key = os.environ.pop("RESEND_API_KEY", None)

Expand Down Expand Up @@ -130,7 +130,7 @@ async def test_send_email_missing_api_key():
finally:
# Restore the original key if it existed
if original_key is not None:
os.environ["RESEND_API_KEY"] = original_key
monkeypatch.setenv("RESEND_API_KEY", original_key)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated


@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def test_send_email_success(mock_env_vars, mock_async_client):


@pytest.mark.asyncio
async def test_send_email_missing_api_key():
async def test_send_email_missing_api_key(monkeypatch):
original_key = os.environ.pop("SENDGRID_API_KEY", None)

try:
Expand All @@ -113,7 +113,7 @@ async def test_send_email_missing_api_key():
)
finally:
if original_key is not None:
os.environ["SENDGRID_API_KEY"] = original_key
monkeypatch.setenv("SENDGRID_API_KEY", original_key)


@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@


class TestGCSBucketBase:
def test_construct_request_headers_with_project_id(self):
def test_construct_request_headers_with_project_id(self, monkeypatch):
"""Test that construct_request_headers correctly uses project_id if passed from env"""
test_project_id = "test-project"
os.environ["GOOGLE_SECRET_MANAGER_PROJECT_ID"] = test_project_id
monkeypatch.setenv("GOOGLE_SECRET_MANAGER_PROJECT_ID", test_project_id)

try:
# Create handler
Expand Down
12 changes: 6 additions & 6 deletions tests/test_litellm/integrations/test_openmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ def test_cloudevents_structure(self):
assert result["data"]["completion_tokens"] == 8
assert result["data"]["total_tokens"] == 23

def test_custom_event_type(self):
def test_custom_event_type(self, monkeypatch):
"""Test that custom event type is used when set"""
os.environ["OPENMETER_EVENT_TYPE"] = "custom_event_type"
monkeypatch.setenv("OPENMETER_EVENT_TYPE", "custom_event_type")

logger = OpenMeterLogger()

Expand Down Expand Up @@ -374,10 +374,10 @@ def test_common_logic_integer_token_user_id(self):
assert isinstance(result["subject"], str)
assert result["subject"] == "12345"

def test_common_logic_trust_request_user_false_ignores_request_user(self):
def test_common_logic_trust_request_user_false_ignores_request_user(self, monkeypatch):
"""OPENMETER_TRUST_REQUEST_USER=false makes the key-bound user_id win
over a request-supplied `user` (forge-attribution mitigation)."""
os.environ["OPENMETER_TRUST_REQUEST_USER"] = "false"
monkeypatch.setenv("OPENMETER_TRUST_REQUEST_USER", "false")
logger = OpenMeterLogger()

kwargs = {
Expand All @@ -400,11 +400,11 @@ def test_common_logic_trust_request_user_false_ignores_request_user(self):
assert result["subject"] == "real-tenant-id"
assert result["subject"] != "forged-by-client"

def test_common_logic_trust_request_user_false_still_raises_without_key_user(self):
def test_common_logic_trust_request_user_false_still_raises_without_key_user(self, monkeypatch):
"""OPENMETER_TRUST_REQUEST_USER=false still raises when no
user_api_key_user_id is available — the request `user` is not a
fallback in this mode."""
os.environ["OPENMETER_TRUST_REQUEST_USER"] = "false"
monkeypatch.setenv("OPENMETER_TRUST_REQUEST_USER", "false")
logger = OpenMeterLogger()

kwargs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def test_bedrock_guardrail_cost_no_pricing_entry(monkeypatch):
assert bedrock_guardrail_cost(usage_units={"contentPolicyUnits": 1}, aws_region_name="us-east-1") == 0.0


def test_shipped_bedrock_guardrail_prices_match_aws_pricing_page():
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
def test_shipped_bedrock_guardrail_prices_match_aws_pricing_page(monkeypatch):
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
litellm.model_cost = litellm.get_model_cost_map(url="")
assert litellm.model_cost["bedrock/guardrails"]["guardrail_cost_per_unit"] == {
"automatedReasoningPolicyUnits": 0.00017,
Expand Down
Loading
Loading