From 1fc103d7275a75fa30200a78cf336ca2782fe0ce Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 10 Sep 2026 09:23:43 +0200 Subject: [PATCH] test(pydantic-ai): Remove vacuous _set_model_data tests --- .../pydantic_ai/test_pydantic_ai.py | 134 ------------------ 1 file changed, 134 deletions(-) diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index ccf16147fd..8cee0a16c3 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -2358,41 +2358,6 @@ async def test_model_name_extraction_fallback_to_str(sentry_init, capture_items) assert isinstance(result, str) -@pytest.mark.asyncio -async def test_model_settings_object_style(sentry_init, capture_items): - """ - Test that object-style model settings (non-dict) are handled correctly. - """ - from unittest.mock import MagicMock - - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_model_data - - sentry_init( - integrations=[PydanticAIIntegration()], - traces_sample_rate=1.0, - ) - - with sentry_sdk.start_transaction(op="test", name="test") as transaction: - span = sentry_sdk.start_span(op="test_span") - - # Create mock settings object (not a dict) - mock_settings = MagicMock() - mock_settings.temperature = 0.8 - mock_settings.max_tokens = 200 - mock_settings.top_p = 0.95 - mock_settings.frequency_penalty = 0.5 - mock_settings.presence_penalty = 0.3 - - # Set model data with object-style settings - _set_model_data(span, None, mock_settings) - - span.finish() - - # Should not crash and should set the settings - assert transaction is not None - - @pytest.mark.parametrize("span_streaming", [True, False]) @pytest.mark.parametrize("stream_gen_ai_spans", [True, False]) @pytest.mark.asyncio @@ -3397,105 +3362,6 @@ async def test_get_model_name_with_none(sentry_init, capture_items): assert result is None -@pytest.mark.asyncio -async def test_set_model_data_with_system(sentry_init, capture_items): - """ - Test that _set_model_data captures system from model. - """ - from unittest.mock import MagicMock - - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_model_data - - sentry_init( - integrations=[PydanticAIIntegration()], - traces_sample_rate=1.0, - ) - - with sentry_sdk.start_transaction(op="test", name="test") as transaction: - span = sentry_sdk.start_span(op="test_span") - - # Create model with system - mock_model = MagicMock() - mock_model.system = "openai" - mock_model.model_name = "gpt-4" - - # Set model data - _set_model_data(span, mock_model, None) - - span.finish() - - # Should not crash - assert transaction is not None - - -@pytest.mark.asyncio -async def test_set_model_data_from_agent_scope(sentry_init, capture_items): - """ - Test that _set_model_data retrieves model from agent in scope when not passed. - """ - from unittest.mock import MagicMock - - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_model_data - - sentry_init( - integrations=[PydanticAIIntegration()], - traces_sample_rate=1.0, - ) - - with sentry_sdk.start_transaction(op="test", name="test") as transaction: - # Set agent in scope - scope = sentry_sdk.get_current_scope() - mock_agent = MagicMock() - mock_agent.model = MagicMock() - mock_agent.model.model_name = "test-model" - mock_agent.model_settings = {"temperature": 0.5} - scope._contexts["pydantic_ai_agent"] = {"_agent": mock_agent} - - span = sentry_sdk.start_span(op="test_span") - - # Pass None for model, should get from scope - _set_model_data(span, None, None) - - span.finish() - - # Should not crash - assert transaction is not None - - -@pytest.mark.asyncio -async def test_set_model_data_with_none_settings_values(sentry_init, capture_items): - """ - Test that _set_model_data skips None values in settings. - """ - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_model_data - - sentry_init( - integrations=[PydanticAIIntegration()], - traces_sample_rate=1.0, - ) - - with sentry_sdk.start_transaction(op="test", name="test") as transaction: - span = sentry_sdk.start_span(op="test_span") - - # Create settings with None values - settings = { - "temperature": 0.7, - "max_tokens": None, # Should be skipped - "top_p": None, # Should be skipped - } - - # Set model data - _set_model_data(span, None, settings) - - span.finish() - - # Should not crash - assert transaction is not None - - @pytest.mark.asyncio async def test_should_send_prompts_without_pii(sentry_init, capture_items): """