Skip to content

Commit

Permalink
Add test_set_dict_class
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Jul 16, 2023
1 parent 684fe36 commit 6abbfca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2933,3 +2933,16 @@ class Meta:
MySchema(unknown="badval")
else:
MySchema().load({"foo": "bar"}, unknown="badval")


@pytest.mark.parametrize("dict_cls", (dict, OrderedDict))
def test_set_dict_class(dict_cls):
"""Demonstrate how to specify dict_class as class attribute"""

class MySchema(Schema):
dict_class = dict_cls
foo = fields.String()

result = MySchema().dump({"foo": "bar"})
assert result == {"foo": "bar"}
assert isinstance(result, dict_cls)

0 comments on commit 6abbfca

Please sign in to comment.