(create_module)
| 154 | |
| 155 | |
| 156 | def test_self_forward_ref_local(create_module): |
| 157 | @create_module |
| 158 | def module(): |
| 159 | from typing import ForwardRef |
| 160 | |
| 161 | from pydantic import BaseModel |
| 162 | |
| 163 | def main(): |
| 164 | Foo = ForwardRef('Foo') |
| 165 | |
| 166 | class Foo(BaseModel): |
| 167 | a: int = 123 |
| 168 | b: Foo = None |
| 169 | |
| 170 | return Foo |
| 171 | |
| 172 | Foo = module.main() |
| 173 | assert Foo().model_dump() == {'a': 123, 'b': None} |
| 174 | assert Foo(b={'a': '321'}).model_dump() == {'a': 123, 'b': {'a': 321, 'b': None}} |
| 175 | |
| 176 | |
| 177 | def test_forward_ref_dataclass(create_module): |
nothing calls this directly
no test coverage detected