Skip to content

Commit dbfba9d

Browse files
committed
test: remove vanilla Pydantic serialization test
The test was originally validating the custom model_serializer on JSONRPCError. With the model_serializer removed in favor of exclude_unset, this test only exercises standard Pydantic behavior. The null-id functionality is covered by E2E tests in test_session.py.
1 parent 75c84bf commit dbfba9d

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

tests/test_types.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import json
21
from typing import Any
32

43
import pytest
54

65
from mcp.types import (
76
LATEST_PROTOCOL_VERSION,
8-
PARSE_ERROR,
97
ClientCapabilities,
108
CreateMessageRequestParams,
119
CreateMessageResult,
1210
CreateMessageResultWithTools,
13-
ErrorData,
1411
Implementation,
1512
InitializeRequest,
1613
InitializeRequestParams,
17-
JSONRPCError,
1814
JSONRPCRequest,
1915
ListToolsResult,
2016
SamplingCapability,
@@ -364,20 +360,3 @@ def test_list_tools_result_preserves_json_schema_2020_12_fields():
364360
assert tool.input_schema["$schema"] == "https://json-schema.org/draft/2020-12/schema"
365361
assert "$defs" in tool.input_schema
366362
assert tool.input_schema["additionalProperties"] is False
367-
368-
369-
def test_jsonrpc_error_null_id_serialization_preserves_id():
370-
"""Test that id: null is preserved in JSON output with exclude_unset=True.
371-
372-
JSON-RPC 2.0 requires the id field to be present with value null for
373-
parse errors, not absent entirely.
374-
"""
375-
error = JSONRPCError(jsonrpc="2.0", id=None, error=ErrorData(code=PARSE_ERROR, message="Parse error"))
376-
serialized = error.model_dump(by_alias=True, exclude_unset=True)
377-
assert "id" in serialized
378-
assert serialized["id"] is None
379-
380-
json_str = error.model_dump_json(by_alias=True, exclude_unset=True)
381-
parsed = json.loads(json_str)
382-
assert "id" in parsed
383-
assert parsed["id"] is None

0 commit comments

Comments
 (0)