88from agents .items import TResponseInputItem
99from agents .exceptions import InputGuardrailTripwireTriggered
1010
11- from .fake_model import FakeModel
1211from openai .types .responses import ResponseCompletedEvent
13- from .test_responses import get_text_message
12+ from tests .fake_model import FakeModel
13+ from tests .test_responses import get_text_message
14+ from tests .testing_processor import fetch_ordered_spans , fetch_events
1415
1516
1617def make_input_guardrail (delay_seconds : float , * , trip : bool ) -> InputGuardrail [Any ]:
@@ -177,8 +178,6 @@ async def test_parent_span_and_trace_finish_after_slow_input_guardrail():
177178 async for _ in result .stream_events ():
178179 pass
179180
180- from .testing_processor import fetch_ordered_spans
181-
182181 spans = fetch_ordered_spans ()
183182 agent_span = _get_span_by_type (spans , "agent" )
184183 guardrail_span = _get_span_by_type (spans , "guardrail" )
@@ -193,8 +192,6 @@ async def test_parent_span_and_trace_finish_after_slow_input_guardrail():
193192 assert _iso (agent_span .ended_at ) >= _iso (generation_span .ended_at )
194193
195194 # Trace should end after all spans end
196- from .testing_processor import fetch_events
197-
198195 events = fetch_events ()
199196 assert events [- 1 ] == "trace_end"
200197
@@ -215,8 +212,6 @@ async def test_parent_span_and_trace_finish_after_slow_model():
215212 async for _ in result .stream_events ():
216213 pass
217214
218- from .testing_processor import fetch_ordered_spans
219-
220215 spans = fetch_ordered_spans ()
221216 agent_span = _get_span_by_type (spans , "agent" )
222217 guardrail_span = _get_span_by_type (spans , "guardrail" )
@@ -230,7 +225,5 @@ async def test_parent_span_and_trace_finish_after_slow_model():
230225 assert _iso (agent_span .ended_at ) >= _iso (guardrail_span .ended_at )
231226 assert _iso (agent_span .ended_at ) >= _iso (generation_span .ended_at )
232227
233- from .testing_processor import fetch_events
234-
235228 events = fetch_events ()
236229 assert events [- 1 ] == "trace_end"
0 commit comments