|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +from collections.abc import Callable |
5 | 6 | from pathlib import Path |
6 | | -from typing import Any |
| 7 | +from typing import TYPE_CHECKING, Any |
| 8 | + |
| 9 | +if TYPE_CHECKING: |
| 10 | + from pydantic_ai.profiles import ModelProfile |
7 | 11 |
|
8 | 12 | import pytest |
9 | 13 | from inline_snapshot import snapshot |
@@ -241,34 +245,29 @@ def test_model_profile(): |
241 | 245 |
|
242 | 246 |
|
243 | 247 | @pytest.mark.parametrize( |
244 | | - 'model_name', |
| 248 | + 'profile_factory', |
245 | 249 | [ |
246 | | - pytest.param('anthropic:claude-sonnet-4-5', id='anthropic'), |
247 | | - pytest.param('google-gla:gemini-2.0-flash', id='google'), |
248 | | - pytest.param('groq:llama-3.3-70b-versatile', id='groq'), |
249 | | - pytest.param('openai:gpt-4o', id='openai'), |
250 | | - pytest.param('openai-responses:gpt-4o', id='openai-responses'), |
251 | | - pytest.param('function', id='function'), |
252 | | - pytest.param('test', id='test'), |
| 250 | + pytest.param(lambda: __import__('pydantic_ai.profiles', fromlist=['ModelProfile']).ModelProfile(), id='base'), |
| 251 | + pytest.param( |
| 252 | + lambda: __import__('pydantic_ai.profiles.openai', fromlist=['OpenAIModelProfile']).OpenAIModelProfile(), |
| 253 | + id='openai', |
| 254 | + ), |
| 255 | + pytest.param( |
| 256 | + lambda: __import__('pydantic_ai.profiles.google', fromlist=['GoogleModelProfile']).GoogleModelProfile(), |
| 257 | + id='google', |
| 258 | + ), |
| 259 | + pytest.param( |
| 260 | + lambda: __import__('pydantic_ai.profiles.groq', fromlist=['GroqModelProfile']).GroqModelProfile(), |
| 261 | + id='groq', |
| 262 | + ), |
253 | 263 | ], |
254 | 264 | ) |
255 | | -def test_supported_builtin_tools(model_name: str): |
256 | | - """Test model.profile.supported_builtin_tools returns proper tool types.""" |
| 265 | +def test_supported_builtin_tools(profile_factory: Callable[[], ModelProfile]): |
| 266 | + """Test profile.supported_builtin_tools returns proper tool types.""" |
257 | 267 | from pydantic_ai.builtin_tools import AbstractBuiltinTool |
258 | | - from pydantic_ai.models import infer_model |
259 | | - |
260 | | - if model_name == 'function': |
261 | | - from pydantic_ai.models.function import FunctionModel |
262 | | - |
263 | | - model = FunctionModel(lambda m, a: None) # type: ignore |
264 | | - elif model_name == 'test': |
265 | | - from pydantic_ai.models.test import TestModel |
266 | | - |
267 | | - model = TestModel() |
268 | | - else: |
269 | | - model = infer_model(model_name) |
270 | 268 |
|
271 | | - result = model.profile.supported_builtin_tools |
| 269 | + profile: ModelProfile = profile_factory() |
| 270 | + result = profile.supported_builtin_tools |
272 | 271 | assert isinstance(result, frozenset) |
273 | 272 | assert all(issubclass(t, AbstractBuiltinTool) for t in result) |
274 | 273 |
|
|
0 commit comments