MCPcopy
hub / github.com/pydantic/pydantic / test_parse_raw_pass

Function test_parse_raw_pass

tests/test_deprecated.py:277–290  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

275
276
277def 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')

Callers

nothing calls this directly

Calls 2

parse_rawMethod · 0.45
model_dumpMethod · 0.45

Tested by

no test coverage detected