()
| 233 | |
| 234 | @pytest.mark.filterwarnings('ignore:Pydantic V1 style `@root_validator` validators are deprecated.*:DeprecationWarning') |
| 235 | def test_root_validator(): |
| 236 | validator_value = None |
| 237 | |
| 238 | class TestCls: |
| 239 | x = 1 |
| 240 | y = 2 |
| 241 | |
| 242 | class Model(BaseModel): |
| 243 | model_config = ConfigDict(from_attributes=True) |
| 244 | x: int |
| 245 | y: int |
| 246 | z: int |
| 247 | |
| 248 | @root_validator(pre=True) |
| 249 | def change_input_data(cls, value): |
| 250 | nonlocal validator_value |
| 251 | validator_value = value |
| 252 | return {'x': value.x, 'y': value.y, 'z': value.x + value.y} |
| 253 | |
| 254 | model = deprecated_from_orm(Model, TestCls()) |
| 255 | assert model.model_dump() == {'x': 1, 'y': 2, 'z': 3} |
| 256 | # assert isinstance(validator_value, GetterDict) |
| 257 | assert isinstance(validator_value, TestCls) |
| 258 | |
| 259 | |
| 260 | def test_nested_orm(): |
nothing calls this directly
no test coverage detected