Skip to content

Commit 7e95a99

Browse files
committed
fix: Fix test get unknown resource
1 parent 0a221a0 commit 7e95a99

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/server/fastmcp/resources/test_resource_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import pytest
55
from pydantic import AnyUrl, FileUrl
66

7+
from mcp.server.fastmcp.exceptions import ResourceError
78
from mcp.server.fastmcp.resources import FileResource, FunctionResource, ResourceManager, ResourceTemplate
9+
from mcp.types import RESOURCE_NOT_FOUND
810

911

1012
@pytest.fixture
@@ -113,8 +115,10 @@ def greet(name: str) -> str:
113115
async def test_get_unknown_resource(self):
114116
"""Test getting a non-existent resource."""
115117
manager = ResourceManager()
116-
with pytest.raises(ValueError, match="Unknown resource"):
118+
with pytest.raises(ResourceError) as exc_info:
117119
await manager.get_resource(AnyUrl("unknown://test"))
120+
assert exc_info.value.error.code == RESOURCE_NOT_FOUND
121+
assert "Unknown resource" in str(exc_info.value)
118122

119123
def test_list_resources(self, temp_file: Path):
120124
"""Test listing all resources."""

0 commit comments

Comments
 (0)