Skip to content

Commit 0a21f84

Browse files
committed
Fix tests
1 parent f88dc59 commit 0a21f84

File tree

6 files changed

+9
-50
lines changed

6 files changed

+9
-50
lines changed

pydantic_ai_slim/pydantic_ai/toolsets/abstract.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,3 @@ def renamed(self, name_map: dict[str, str]) -> RenamedToolset[AgentDepsT]:
149149
from .renamed import RenamedToolset
150150

151151
return RenamedToolset(self, name_map)
152-
153-

pydantic_ai_slim/pydantic_ai/toolsets/combined.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ async def call_tool(
7171

7272
def apply(self, visitor: Callable[[AbstractToolset[AgentDepsT]], None]) -> None:
7373
for toolset in self.toolsets:
74-
toolset.apply(visitor)
74+
toolset.apply(visitor)

pydantic_ai_slim/pydantic_ai/toolsets/dynamic.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/test_examples.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,6 @@ def rich_prompt_ask(prompt: str, *_args: Any, **_kwargs: Any) -> str:
269269

270270

271271
class MockMCPServer(AbstractToolset[Any]):
272-
async def __aenter__(self) -> MockMCPServer:
273-
return self
274-
275-
async def __aexit__(self, *args: Any) -> None:
276-
pass
277-
278272
async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]:
279273
return {}
280274

tests/test_mcp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ async def test_context_manager_initialization_error() -> None:
9696
server = MCPServerStdio('python', ['-m', 'tests.mcp_server'])
9797
from mcp.client.session import ClientSession
9898

99+
with pytest.raises(Exception):
100+
_ = server.client
101+
99102
with patch.object(ClientSession, 'initialize', side_effect=Exception):
100103
with pytest.raises(Exception):
101104
async with server.setup():

tests/test_toolsets.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
from collections.abc import AsyncGenerator
66
from contextlib import asynccontextmanager
77
from dataclasses import dataclass, replace
8-
from typing import Any, Self, TypeVar
8+
from typing import Any, TypeVar
99

1010
import pytest
1111
from inline_snapshot import snapshot
12+
from typing_extensions import Self
1213

1314
from pydantic_ai._run_context import RunContext
1415
from pydantic_ai._tool_manager import ToolManager
@@ -491,15 +492,13 @@ class FailingToolset(AbstractToolset[Any]):
491492
async def setup(self) -> AsyncGenerator[Self, Any]:
492493
raise InitializationError
493494

494-
yield self
495+
yield self # pragma: no cover
495496

496-
async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]:
497-
return {}
497+
async def get_tools(self, ctx: RunContext[Any]) -> dict[str, ToolsetTool[Any]]: ...
498498

499499
async def call_tool(
500500
self, name: str, tool_args: dict[str, Any], ctx: RunContext[Any], tool: ToolsetTool[Any]
501-
) -> Any:
502-
return None
501+
) -> Any: ...
503502

504503
server1 = MCPServerStdio('python', ['-m', 'tests.mcp_server'])
505504
server2 = FailingToolset()

0 commit comments

Comments
 (0)