MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / test_by_alias

Method test_by_alias

tests/test_pydantic.py:114–130  ·  view source on GitHub ↗

Test using field aliases.

(self)

Source from the content-addressed store, hash-verified

112 assert 'email' not in toon_no_none
113
114 def test_by_alias(self):
115 """Test using field aliases."""
116 class User(BaseModel):
117 user_id: int = Field(alias='id')
118 user_name: str = Field(alias='name')
119
120 user = User(id=1, name='Alice')
121
122 # Without alias
123 toon_no_alias = encode_pydantic(user, by_alias=False)
124 assert 'user_id: 1' in toon_no_alias
125 assert 'user_name: Alice' in toon_no_alias
126
127 # With alias
128 toon_alias = encode_pydantic(user, by_alias=True)
129 assert 'id: 1' in toon_alias
130 assert 'name: Alice' in toon_alias
131
132 def test_with_encoding_options(self):
133 """Test encoding with custom TOON options."""

Callers

nothing calls this directly

Calls 2

encode_pydanticFunction · 0.90
UserClass · 0.70

Tested by

no test coverage detected