MCPcopy
hub / github.com/pydantic/pydantic / module

Function module

tests/test_forward_ref.py:47–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45def test_forward_ref_auto_update_no_model(create_module):
46 @create_module
47 def module():
48 from typing import Optional
49
50 import pytest
51
52 from pydantic import BaseModel, PydanticUserError
53
54 class Foo(BaseModel):
55 a: Optional['Bar'] = None
56
57 with pytest.raises(PydanticUserError, match='`Foo` is not fully defined; you should define `Bar`,'):
58 Foo(a={'b': {'a': {}}})
59
60 class Bar(BaseModel):
61 b: 'Foo'
62
63 assert module.Bar.__pydantic_complete__ is True
64 assert module.Bar.model_fields['b']._complete

Callers

nothing calls this directly

Calls 6

model_rebuildMethod · 0.80
FooClass · 0.70
MainClass · 0.70
FoobarClass · 0.70
create_modelMethod · 0.45
model_dumpMethod · 0.45

Tested by

no test coverage detected