MCPcopy
hub / github.com/pydantic/pydantic / test_not_required

Function test_not_required

tests/test_main.py:249–264  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247
248
249def 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
267def test_allow_extra():

Callers

nothing calls this directly

Calls 2

ModelClass · 0.70
errorsMethod · 0.45

Tested by

no test coverage detected