MCPcopy
hub / github.com/pydantic/pydantic / test_validate_by_name_config

Method test_validate_by_name_config

tests/test_config.py:322–341  ·  view source on GitHub ↗
(
        self,
        use_construct: bool,
        validate_by_name_config: bool,
        arg_name: str,
        expectation: AbstractContextManager,
    )

Source from the content-addressed store, hash-verified

320 ],
321 )
322 def test_validate_by_name_config(
323 self,
324 use_construct: bool,
325 validate_by_name_config: bool,
326 arg_name: str,
327 expectation: AbstractContextManager,
328 ):
329 expected_value: int = 7
330
331 class Foo(BaseModel):
332 bar_: int = Field(alias='bar')
333
334 model_config = dict(validate_by_name=validate_by_name_config)
335
336 with expectation:
337 if use_construct:
338 f = Foo.model_construct(**{arg_name: expected_value})
339 else:
340 f = Foo(**{arg_name: expected_value})
341 assert f.bar_ == expected_value
342
343 def test_immutable_copy_with_frozen(self):
344 class Model(BaseModel):

Callers

nothing calls this directly

Calls 2

FooClass · 0.70
model_constructMethod · 0.45

Tested by

no test coverage detected