MCPcopy
hub / github.com/fastapi/fastapi / test_encode_model_with_default

Function test_encode_model_with_default

tests/test_jsonable_encoder.py:187–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185
186
187def test_encode_model_with_default():
188 model = ModelWithDefault(foo="foo", bar="bar")
189 assert jsonable_encoder(model) == {"foo": "foo", "bar": "bar", "bla": "bla"}
190 assert jsonable_encoder(model, exclude_unset=True) == {"foo": "foo", "bar": "bar"}
191 assert jsonable_encoder(model, exclude_defaults=True) == {"foo": "foo"}
192 assert jsonable_encoder(model, exclude_unset=True, exclude_defaults=True) == {
193 "foo": "foo"
194 }
195 assert jsonable_encoder(model, include={"foo"}) == {"foo": "foo"}
196 assert jsonable_encoder(model, exclude={"bla"}) == {"foo": "foo", "bar": "bar"}
197 assert jsonable_encoder(model, include={}) == {}
198 assert jsonable_encoder(model, exclude={}) == {
199 "foo": "foo",
200 "bar": "bar",
201 "bla": "bla",
202 }
203
204
205def test_custom_encoders():

Callers

nothing calls this directly

Calls 2

jsonable_encoderFunction · 0.90
ModelWithDefaultClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…