Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 790 Bytes

File metadata and controls

25 lines (17 loc) · 790 Bytes

pydantic_ai.models.test

Utility model for quickly testing apps built with Pydantic AI.

Here's a minimal example:

from pydantic_ai import Agent
from pydantic_ai.models.test import TestModel

my_agent = Agent('openai:gpt-5', instructions='...')


async def test_my_agent():
    """Unit test for my_agent, to be run by pytest."""
    m = TestModel()
    with my_agent.override(model=m):
        result = await my_agent.run('Testing my agent...')
        assert result.output == 'success (no tool calls)'
    assert m.last_model_request_parameters.function_tools == []

See Unit testing with TestModel for detailed documentation.

::: pydantic_ai.models.test