Skip to content

Commit 4bc0e48

Browse files
committed
test: close logging coverage gaps
1 parent 01f3c0a commit 4bc0e48

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

tests/cli/test_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from mcp.cli.cli import ( # type: ignore[reportPrivateUsage]
99
_build_uv_command,
1010
_get_npx_command,
11+
_get_server_log_level,
1112
_parse_file_path,
1213
run,
1314
)
@@ -78,6 +79,16 @@ def fake_configure_logging(level: str) -> None:
7879
]
7980

8081

82+
def test_get_server_log_level_defaults_invalid_setting():
83+
class Settings:
84+
log_level = "VERBOSE"
85+
86+
class Server:
87+
settings = Settings()
88+
89+
assert _get_server_log_level(Server()) == "INFO"
90+
91+
8192
def test_build_uv_command_minimal():
8293
"""Should emit core command when no extras specified."""
8394
cmd = _build_uv_command("foo.py")

tests/server/mcpserver/test_server.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@
4848

4949
class TestServer:
5050
def test_create_server_does_not_configure_application_logging(self, monkeypatch: pytest.MonkeyPatch):
51-
calls: list[tuple[tuple[Any, ...], dict[str, Any]]] = []
52-
53-
def fake_basic_config(*args: Any, **kwargs: Any) -> None:
54-
calls.append((args, kwargs))
55-
56-
monkeypatch.setattr(logging, "basicConfig", fake_basic_config)
51+
basic_config = MagicMock()
52+
monkeypatch.setattr(logging, "basicConfig", basic_config)
5753

5854
MCPServer("test")
5955

60-
assert calls == []
56+
basic_config.assert_not_called()
6157

6258
async def test_create_server(self):
6359
mcp = MCPServer(

0 commit comments

Comments
 (0)