diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 03f468e497..ccf16147fd 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -3517,95 +3517,6 @@ async def test_should_send_prompts_without_pii(sentry_init, capture_items): assert _should_send_outputs() is False -@pytest.mark.asyncio -async def test_set_agent_data_without_agent(sentry_init, capture_items): - """ - Test that _set_agent_data handles None agent gracefully. - """ - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_agent_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") - - # Pass None agent, with no agent in scope - _set_agent_data(span, None) - - span.finish() - - # Should not crash - assert transaction is not None - - -@pytest.mark.asyncio -async def test_set_agent_data_from_scope(sentry_init, capture_items): - """ - Test that _set_agent_data retrieves agent from scope when not passed. - """ - from unittest.mock import MagicMock - - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_agent_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.name = "test_agent_from_scope" - scope._contexts["pydantic_ai_agent"] = {"_agent": mock_agent} - - span = sentry_sdk.start_span(op="test_span") - - # Pass None for agent, should get from scope - _set_agent_data(span, None) - - span.finish() - - # Should not crash - assert transaction is not None - - -@pytest.mark.asyncio -async def test_set_agent_data_without_name(sentry_init, capture_items): - """ - Test that _set_agent_data handles agent without name attribute. - """ - from unittest.mock import MagicMock - - import sentry_sdk - from sentry_sdk.integrations.pydantic_ai.utils import _set_agent_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 agent without name - mock_agent = MagicMock() - mock_agent.name = None # No name - - # Should not set agent name - _set_agent_data(span, mock_agent) - - span.finish() - - # Should not crash - assert transaction is not None - - @pytest.mark.asyncio async def test_set_available_tools_without_toolset(sentry_init, capture_items): """