MCPcopy
hub / github.com/pydantic/pydantic / test_json

Function test_json

tests/test_deprecated.py:674–687  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

672
673
674def test_json():
675 m = SimpleModel(x=1)
676 with pytest.warns(
677 PydanticDeprecatedSince20, match=r'^The `json` method is deprecated; use `model_dump_json` instead\.'
678 ):
679 assert m.json() == '{"x":1}'
680
681 with pytest.warns(PydanticDeprecatedSince20):
682 with pytest.raises(TypeError, match='The `encoder` argument is no longer supported'):
683 m.json(encoder=1)
684 with pytest.raises(TypeError, match='The `models_as_dict` argument is no longer supported'):
685 m.json(models_as_dict=True)
686 with pytest.raises(TypeError, match='`dumps_kwargs` keyword arguments are no longer supported.'):
687 m.json(foo=4)
688
689
690def test_parse_obj():

Callers

nothing calls this directly

Calls 2

SimpleModelClass · 0.70
jsonMethod · 0.45

Tested by

no test coverage detected