()
| 275 | |
| 276 | |
| 277 | def test_parse_raw_pass(): |
| 278 | class Model(BaseModel): |
| 279 | x: int |
| 280 | y: int |
| 281 | |
| 282 | with pytest.warns(PydanticDeprecatedSince20) as all_warnings: |
| 283 | model = Model.parse_raw('{"x": 1, "y": 2}') |
| 284 | assert model.model_dump() == {'x': 1, 'y': 2} |
| 285 | assert len(all_warnings) == 2 |
| 286 | expected_warnings = [ |
| 287 | 'The `parse_raw` method is deprecated; if your data is JSON use `model_validate_json`, otherwise load the data then use `model_validate` instead', |
| 288 | '`load_str_bytes` is deprecated', |
| 289 | ] |
| 290 | assert [w.message.message for w in all_warnings] == expected_warnings |
| 291 | |
| 292 | |
| 293 | @pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='Different error str on PyPy') |
nothing calls this directly
no test coverage detected