Test using field aliases.
(self)
| 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.""" |
nothing calls this directly
no test coverage detected