MCPcopy
hub / github.com/pydantic/pydantic / test_extra_ignored

Function test_extra_ignored

tests/test_main.py:403–414  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

401
402
403def test_extra_ignored():
404 class Model(BaseModel):
405 model_config = ConfigDict(extra='ignore')
406 a: float
407
408 model = Model(a=0.2, b=0.1)
409 assert not hasattr(model, 'b')
410
411 with pytest.raises(ValueError, match='"Model" object has no field "b"'):
412 model.b = 1
413
414 assert model.model_extra is None
415
416
417def test_field_order_is_preserved_with_extra():

Callers

nothing calls this directly

Calls 1

ModelClass · 0.70

Tested by

no test coverage detected