Skip to content

Commit

Permalink
feat: add ListField
Browse files Browse the repository at this point in the history
  • Loading branch information
pity7736 committed Feb 23, 2022
1 parent f4f6c65 commit 8c2616b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
44 changes: 44 additions & 0 deletions nyoibo/fields.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions nyoibo/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,8 @@ class JSONField(Field):
class TupleField(Field):

_internal_type = tuple


class ListField(Field):

_internal_type = list
5 changes: 5 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,8 @@ def test_parse_json_field_with_invalid_data():
def test_parse_tuple_field():
field = fields.TupleField()
assert field.parse([1, 2, 3]) == (1, 2, 3)


def test_parse_list_field():
field = fields.ListField()
assert field.parse((1, 2, 3)) == [1, 2, 3]

0 comments on commit 8c2616b

Please sign in to comment.