()
| 247 | |
| 248 | |
| 249 | def test_not_required(): |
| 250 | class Model(BaseModel): |
| 251 | a: float = None |
| 252 | |
| 253 | assert Model(a=12.2).a == 12.2 |
| 254 | assert Model().a is None |
| 255 | with pytest.raises(ValidationError) as exc_info: |
| 256 | Model(a=None) |
| 257 | assert exc_info.value.errors(include_url=False) == [ |
| 258 | { |
| 259 | 'type': 'float_type', |
| 260 | 'loc': ('a',), |
| 261 | 'msg': 'Input should be a valid number', |
| 262 | 'input': None, |
| 263 | }, |
| 264 | ] |
| 265 | |
| 266 | |
| 267 | def test_allow_extra(): |