MCPcopy
hub / github.com/fastapi/fastapi / test_encode_dataclass

Function test_encode_dataclass

tests/test_jsonable_encoder.py:125–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123
124
125def test_encode_dataclass():
126 item = Item(name="foo", count=100)
127 assert jsonable_encoder(item) == {"name": "foo", "count": 100}
128 assert jsonable_encoder(item, include={"name"}) == {"name": "foo"}
129 assert jsonable_encoder(item, exclude={"count"}) == {"name": "foo"}
130 assert jsonable_encoder(item, include={}) == {}
131 assert jsonable_encoder(item, exclude={}) == {"name": "foo", "count": 100}
132
133
134def test_encode_unsupported():

Callers

nothing calls this directly

Calls 2

jsonable_encoderFunction · 0.90
ItemClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…