Skip to content
Merged
Changes from all commits
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
27 changes: 21 additions & 6 deletions tests/integrations/pydantic_ai/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from sentry_sdk.integrations.pydantic_ai import PydanticAIIntegration
from sentry_sdk.integrations.pydantic_ai.spans.ai_client import _set_input_messages
from sentry_sdk.integrations.pydantic_ai.spans.utils import _set_usage_data
from sentry_sdk.utils import package_version

PYDANTIC_AI_VERSION = package_version("pydantic-ai")


@pytest.fixture
Expand Down Expand Up @@ -517,10 +520,17 @@ async def test_agent_run_stream_events(
if stream_gen_ai_spans:
items = capture_items("transaction", "span")

async for _ in test_agent.run_stream_events(
["Message demonstrating the absence of truncation.", "Test input"]
):
pass
if PYDANTIC_AI_VERSION > (2,):
async with test_agent.run_stream_events(
["Message demonstrating the absence of truncation.", "Test input"]
) as stream_events:
async for _ in stream_events:
pass
else:
async for _ in test_agent.run_stream_events(
["Message demonstrating the absence of truncation.", "Test input"]
Comment thread
alexander-alderman-webb marked this conversation as resolved.
):
pass
Comment thread
alexander-alderman-webb marked this conversation as resolved.

Comment thread
alexander-alderman-webb marked this conversation as resolved.
# Verify transaction
(transaction,) = (item.payload for item in items if item.type == "transaction")
Expand All @@ -541,8 +551,13 @@ async def test_agent_run_stream_events(
else:
events = capture_events()

async for _ in test_agent.run_stream_events("Test input"):
pass
if PYDANTIC_AI_VERSION > (2,):
async with test_agent.run_stream_events("Test input") as stream_events:
async for _ in stream_events:
pass
else:
async for _ in test_agent.run_stream_events("Test input"):
pass

(transaction,) = events

Expand Down
Loading