()
| 221 | |
| 222 | |
| 223 | def test_schema_class(): |
| 224 | class Model(BaseModel): |
| 225 | foo: int = Field(4, title='Foo is Great') |
| 226 | bar: str = Field(description='this description of bar') |
| 227 | |
| 228 | with pytest.raises(ValidationError): |
| 229 | Model() |
| 230 | |
| 231 | m = Model(bar='123') |
| 232 | assert m.model_dump() == {'foo': 4, 'bar': '123'} |
| 233 | |
| 234 | assert Model.model_json_schema() == { |
| 235 | 'type': 'object', |
| 236 | 'title': 'Model', |
| 237 | 'properties': { |
| 238 | 'foo': {'type': 'integer', 'title': 'Foo is Great', 'default': 4}, |
| 239 | 'bar': {'type': 'string', 'title': 'Bar', 'description': 'this description of bar'}, |
| 240 | }, |
| 241 | 'required': ['bar'], |
| 242 | } |
| 243 | |
| 244 | |
| 245 | def test_schema_repr(): |
nothing calls this directly
no test coverage detected