Skip to content

Commit 57954d4

Browse files
committed
update
1 parent d6f13c9 commit 57954d4

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ MD059=false # descriptive-link-text
165165

166166
# https://coverage.readthedocs.io/en/latest/config.html#run
167167
[tool.coverage.run]
168-
brach = true
168+
branch = true
169169
patch = ["subprocess"]
170170
concurrency = ["multiprocessing", "thread"]
171171
source = ["src", "tests"]

tests/test_examples.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
"""Tests for example servers"""
2+
23
# TODO(Marcelo): The `examples` directory needs to be importable as a package.
34
# pyright: reportMissingImports=false
45
# pyright: reportUnknownVariableType=false
56
# pyright: reportUnknownArgumentType=false
67
# pyright: reportUnknownMemberType=false
7-
88
import sys
9+
from pathlib import Path
910

1011
import pytest
12+
from pydantic import AnyUrl
1113
from pytest_examples import CodeExample, EvalExample, find_examples
1214

15+
from examples.fastmcp.desktop import mcp
1316
from mcp.shared.memory import create_connected_server_and_client_session as client_session
1417
from mcp.types import TextContent, TextResourceContents
1518

@@ -45,13 +48,23 @@ async def test_complex_inputs():
4548

4649

4750
@pytest.mark.anyio
48-
async def test_desktop(monkeypatch: pytest.MonkeyPatch):
51+
@pytest.mark.parametrize(
52+
"files",
53+
[
54+
pytest.param(
55+
["/fake/path/file1.txt", "/fake/path/file2.txt"],
56+
id="unix",
57+
marks=pytest.mark.skipif(sys.platform == "win32", reason="Unix-specific test"),
58+
),
59+
pytest.param(
60+
["C:\\fake\\path\\file1.txt", "C:\\fake\\path\\file2.txt"],
61+
id="windows",
62+
marks=pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific test"),
63+
),
64+
],
65+
)
66+
async def test_desktop(monkeypatch: pytest.MonkeyPatch, files: list[str]):
4967
"""Test the desktop server"""
50-
from pathlib import Path
51-
52-
from pydantic import AnyUrl
53-
54-
from examples.fastmcp.desktop import mcp
5568

5669
# Mock desktop directory listing
5770
mock_files = [Path("/fake/path/file1.txt"), Path("/fake/path/file2.txt")]
@@ -72,15 +85,7 @@ async def test_desktop(monkeypatch: pytest.MonkeyPatch):
7285
content = result.contents[0]
7386
assert isinstance(content, TextResourceContents)
7487
assert isinstance(content.text, str)
75-
if sys.platform == "win32":
76-
file_1 = "/fake/path/file1.txt".replace("/", "\\\\") # might be a bug
77-
file_2 = "/fake/path/file2.txt".replace("/", "\\\\") # might be a bug
78-
assert file_1 in content.text
79-
assert file_2 in content.text
80-
# might be a bug, but the test is passing
81-
else:
82-
assert "/fake/path/file1.txt" in content.text
83-
assert "/fake/path/file2.txt" in content.text
88+
assert all(file in content.text for file in files)
8489

8590

8691
@pytest.mark.parametrize("example", find_examples("README.md"), ids=str)

0 commit comments

Comments
 (0)