Fix Issue #5301. Fix docs + allow None to be passed in to child + tests

This commit is contained in:
Arijeet Mukherjee 2017-08-03 01:21:00 +05:30
parent edad462ca3
commit f485099474
2 changed files with 16 additions and 2 deletions

View File

@ -1522,7 +1522,7 @@ class ListField(Field):
}
def __init__(self, *args, **kwargs):
child = kwargs.pop('child')
child = kwargs.pop('child', None)
if child is None:
child = copy.deepcopy(self.child)
self.child = child
@ -1586,7 +1586,7 @@ class DictField(Field):
}
def __init__(self, *args, **kwargs):
child = kwargs.pop('child')
child = kwargs.pop('child', None)
if child is None:
child = copy.deepcopy(self.child)
self.child = child

View File

@ -1734,6 +1734,13 @@ class TestUnvalidatedListField(FieldValues):
field = serializers.ListField()
class TestUnvalidatedListFieldWithChildNone(TestUnvalidatedListField):
"""
Values for `ListField` with `child=None`.
"""
field = serializers.ListField(child=None)
class TestDictField(FieldValues):
"""
Values for `ListField` with CharField as child.
@ -1799,6 +1806,13 @@ class TestUnvalidatedDictField(FieldValues):
field = serializers.DictField()
class TestUnvalidatedDictFieldWithChildNone(TestUnvalidatedDictField):
"""
Values for `ListField` with `child=None`.
"""
field = serializers.DictField(child=None)
class TestJSONField(FieldValues):
"""
Values for `JSONField`.