Skip to content

Commit 710496a

Browse files
test(pydantic_ai): Filter spans by op to prevent fragile assertion
1 parent 1939fb9 commit 710496a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

tests/integrations/pydantic_ai/test_pydantic_ai.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2693,7 +2693,9 @@ async def test_binary_content_encoding_mixed_content(sentry_init, capture_events
26932693
await agent.run(["Here is an image:", binary_content, "What do you see?"])
26942694

26952695
(event,) = events
2696-
span_data = event["spans"][0]["data"]
2696+
chat_spans = [s for s in event.get("spans", []) if s.get("op") == "gen_ai.chat"]
2697+
assert chat_spans, "Sentry should have captured a gen_ai.chat span"
2698+
span_data = chat_spans[0].get("data", {})
26972699
messages_data = _get_messages_from_span(span_data)
26982700

26992701
# Verify both text and binary content are present

0 commit comments

Comments
 (0)