MCPcopy
hub / github.com/pydantic/pydantic / test_parse_file

Function test_parse_file

tests/test_deprecated.py:699–711  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

697
698
699def test_parse_file(tmp_path):
700 path = tmp_path / 'test.json'
701 path.write_text('{"x": 12}')
702 with pytest.warns(PydanticDeprecatedSince20) as all_warnings:
703 assert SimpleModel.parse_file(str(path)).model_dump() == {'x': 12}
704 assert len(all_warnings) == 4
705 expected_warnings = [
706 'The `parse_file` method is deprecated; load the data from file, then if your data is JSON use `model_validate_json`, otherwise `model_validate` instead',
707 '`load_file` is deprecated',
708 '`load_str_bytes` is deprecated',
709 'The `parse_obj` method is deprecated; use `model_validate` instead',
710 ]
711 assert [w.message.message for w in all_warnings] == expected_warnings
712
713
714def test_construct():

Callers

nothing calls this directly

Calls 2

model_dumpMethod · 0.45
parse_fileMethod · 0.45

Tested by

no test coverage detected