()
| 2310 | |
| 2311 | |
| 2312 | def test_optional_dict(): |
| 2313 | class Model(BaseModel): |
| 2314 | something: Optional[dict[str, Any]] = None |
| 2315 | |
| 2316 | assert Model.model_json_schema() == { |
| 2317 | 'title': 'Model', |
| 2318 | 'type': 'object', |
| 2319 | 'properties': { |
| 2320 | 'something': { |
| 2321 | 'anyOf': [{'type': 'object', 'additionalProperties': True}, {'type': 'null'}], |
| 2322 | 'default': None, |
| 2323 | 'title': 'Something', |
| 2324 | } |
| 2325 | }, |
| 2326 | } |
| 2327 | |
| 2328 | assert Model().model_dump() == {'something': None} |
| 2329 | assert Model(something={'foo': 'Bar'}).model_dump() == {'something': {'foo': 'Bar'}} |
| 2330 | |
| 2331 | |
| 2332 | def test_optional_validator(): |
nothing calls this directly
no test coverage detected