Skip to content

Commit 2716d09

Browse files
committed
Pin the decorator's refusal messages and describe two wire-base tests
The two `@deferred_model` refusals asserted only the exception type; they now snapshot the message so a wording change is a deliberate diff rather than a silent one. The first two wire-base tests gain the provenance docstrings the rest of the file carries.
1 parent cb7c68c commit 2716d09

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

tests/types/test_deferred.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import typing
1010

1111
import pytest
12+
from inline_snapshot import snapshot
1213
from mcp_types import Implementation, Tool
1314
from mcp_types._deferred import deferred_model
1415
from mcp_types._types import MCPModel
@@ -87,10 +88,12 @@ class OwnsHook(BaseModel):
8788
def __pydantic_init_subclass__(cls, **kwargs: object) -> None:
8889
raise NotImplementedError # never runs: the decorator refuses the class first
8990

90-
with pytest.raises(TypeError):
91+
with pytest.raises(TypeError) as eager_error:
9192
deferred_model(Eager)
92-
with pytest.raises(TypeError):
93+
assert str(eager_error.value) == snapshot("@deferred_model expects Eager to set model_config['defer_build'] = True")
94+
with pytest.raises(TypeError) as hook_error:
9395
deferred_model(OwnsHook)
96+
assert str(hook_error.value) == snapshot("@deferred_model would replace OwnsHook's own __pydantic_init_subclass__")
9497

9598

9699
def test_unresolvable_model_falls_back_to_the_generic_signature() -> None:

tests/types/test_wire_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88

99
def test_wire_model_defers_the_pydantic_build_to_first_use() -> None:
10+
"""SDK-defined: a `WireModel` subclass creates its class without building a validator;
11+
the first `model_validate` builds it, once."""
12+
1013
class Probe(WireModel):
1114
x: int
1215

@@ -16,6 +19,9 @@ class Probe(WireModel):
1619

1720

1821
def test_wire_root_model_defers_the_parameterized_base_and_the_alias() -> None:
22+
"""SDK-defined: a `WireRootModel[T]` alias defers both itself and its generic
23+
parameterization, and still validates through the root on first use."""
24+
1925
class Payload(WireModel):
2026
x: int
2127

0 commit comments

Comments
 (0)