Test excluding unset fields.
(self)
| 75 | assert 'zipcode: 02101' in toon |
| 76 | |
| 77 | def test_exclude_unset(self): |
| 78 | """Test excluding unset fields.""" |
| 79 | class Config(BaseModel): |
| 80 | host: str |
| 81 | port: int = 8080 |
| 82 | debug: bool = False |
| 83 | |
| 84 | config = Config(host='localhost') |
| 85 | |
| 86 | # With exclude_unset=False (default) |
| 87 | toon_all = encode_pydantic(config, exclude_unset=False) |
| 88 | assert 'port: 8080' in toon_all |
| 89 | assert 'debug: false' in toon_all |
| 90 | |
| 91 | # With exclude_unset=True |
| 92 | toon_set = encode_pydantic(config, exclude_unset=True) |
| 93 | assert 'host: localhost' in toon_set |
| 94 | assert 'port' not in toon_set |
| 95 | assert 'debug' not in toon_set |
| 96 | |
| 97 | def test_exclude_none(self): |
| 98 | """Test excluding None values.""" |
nothing calls this directly
no test coverage detected