MCPcopy
hub / github.com/pydantic/pydantic / test_extra_allow_from_orm

Function test_extra_allow_from_orm

tests/test_deprecated.py:220–231  ·  view source on GitHub ↗
(extra: Literal['ignore', 'forbid', 'allow'])

Source from the content-addressed store, hash-verified

218
219@pytest.mark.parametrize('extra', ['ignore', 'forbid', 'allow'])
220def test_extra_allow_from_orm(extra: Literal['ignore', 'forbid', 'allow']):
221 class TestCls:
222 x = 1
223 y = 2
224
225 class Model(BaseModel):
226 model_config = ConfigDict(from_attributes=True, extra=extra)
227 x: int
228
229 model = deprecated_from_orm(Model, TestCls())
230 assert model.x == 1
231 assert not hasattr(model, 'y')
232
233
234@pytest.mark.filterwarnings('ignore:Pydantic V1 style `@root_validator` validators are deprecated.*:DeprecationWarning')

Callers

nothing calls this directly

Calls 2

deprecated_from_ormFunction · 0.85
TestClsClass · 0.85

Tested by

no test coverage detected