Test excluding None values.
(self)
| 95 | assert 'debug' not in toon_set |
| 96 | |
| 97 | def test_exclude_none(self): |
| 98 | """Test excluding None values.""" |
| 99 | class User(BaseModel): |
| 100 | id: int |
| 101 | name: str |
| 102 | email: str | None = None # Use | syntax for Python 3.10+ |
| 103 | |
| 104 | user = User(id=1, name='Alice', email=None) |
| 105 | |
| 106 | # With exclude_none=False (default) |
| 107 | toon_all = encode_pydantic(user, exclude_none=False) |
| 108 | assert 'email: null' in toon_all |
| 109 | |
| 110 | # With exclude_none=True |
| 111 | toon_no_none = encode_pydantic(user, exclude_none=True) |
| 112 | assert 'email' not in toon_no_none |
| 113 | |
| 114 | def test_by_alias(self): |
| 115 | """Test using field aliases.""" |
nothing calls this directly
no test coverage detected