|
24 | 24 | ToolOutputSchema,
|
25 | 25 | )
|
26 | 26 | from pydantic_ai.agent import AgentRunResult
|
27 |
| -from pydantic_ai.mcp import MCPServerStdio |
28 | 27 | from pydantic_ai.messages import (
|
29 | 28 | BinaryContent,
|
30 | 29 | ImageUrl,
|
@@ -3442,13 +3441,18 @@ def test_deprecated_kwargs_still_work():
|
3442 | 3441 | assert issubclass(w[0].category, DeprecationWarning)
|
3443 | 3442 | assert '`result_retries` is deprecated' in str(w[0].message)
|
3444 | 3443 |
|
3445 |
| - with warnings.catch_warnings(record=True) as w: |
3446 |
| - warnings.simplefilter('always') |
| 3444 | + try: |
| 3445 | + from pydantic_ai.mcp import MCPServerStdio |
3447 | 3446 |
|
3448 |
| - agent = Agent('test', mcp_servers=[MCPServerStdio('python', ['-m', 'tests.mcp_server'])]) # type: ignore[call-arg] |
3449 |
| - assert len(w) == 1 |
3450 |
| - assert issubclass(w[0].category, DeprecationWarning) |
3451 |
| - assert '`mcp_servers` is deprecated' in str(w[0].message) |
| 3447 | + with warnings.catch_warnings(record=True) as w: |
| 3448 | + warnings.simplefilter('always') |
| 3449 | + |
| 3450 | + agent = Agent('test', mcp_servers=[MCPServerStdio('python', ['-m', 'tests.mcp_server'])]) # type: ignore[call-arg] |
| 3451 | + assert len(w) == 1 |
| 3452 | + assert issubclass(w[0].category, DeprecationWarning) |
| 3453 | + assert '`mcp_servers` is deprecated' in str(w[0].message) |
| 3454 | + except ImportError: |
| 3455 | + pass |
3452 | 3456 |
|
3453 | 3457 |
|
3454 | 3458 | def test_deprecated_kwargs_mixed_valid_invalid():
|
@@ -3604,6 +3608,11 @@ async def test_reentrant_context_manager():
|
3604 | 3608 |
|
3605 | 3609 |
|
3606 | 3610 | def test_set_mcp_sampling_model():
|
| 3611 | + try: |
| 3612 | + from pydantic_ai.mcp import MCPServerStdio |
| 3613 | + except ImportError: |
| 3614 | + return |
| 3615 | + |
3607 | 3616 | test_model = TestModel()
|
3608 | 3617 | server1 = MCPServerStdio('python', ['-m', 'tests.mcp_server'])
|
3609 | 3618 | server2 = MCPServerStdio('python', ['-m', 'tests.mcp_server'], sampling_model=test_model)
|
|
0 commit comments