Skip to content

Commit e1765d3

Browse files
committed
add fixture override
1 parent 5ec9b49 commit e1765d3

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

pydantic_ai_slim/pydantic_ai/agent/abstract.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,18 +614,6 @@ def run_stream_sync(
614614
If you want to always run the agent graph to completion and stream events and output at the same time,
615615
use [`agent.run()`][pydantic_ai.agent.AbstractAgent.run] with an `event_stream_handler` or [`agent.iter()`][pydantic_ai.agent.AbstractAgent.iter] instead.
616616
617-
Example:
618-
```python
619-
from pydantic_ai import Agent
620-
621-
agent = Agent('openai:gpt-4o')
622-
623-
def main():
624-
with agent.run_stream_sync('What is the capital of the UK?') as response:
625-
print(response.get_output_sync())
626-
#> The capital of the UK is London.
627-
```
628-
629617
Args:
630618
user_prompt: User input to start/continue the conversation.
631619
output_type: Custom output type to use for this run, `output_type` may only be used if the agent has no

tests/test_streaming.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ async def ret_a(x: str) -> str:
134134
)
135135

136136

137-
def test_streamed_text_sync_response():
137+
@pytest.fixture
138+
def close_cached_httpx_client():
139+
"""Override the global fixture to avoid async context issues in sync tests."""
140+
yield
141+
142+
143+
def test_streamed_text_sync_response(close_cached_httpx_client): # type: ignore[reportUnknownParameterType]
138144
m = TestModel()
139145

140146
test_agent = Agent(m)

0 commit comments

Comments
 (0)