mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Test cases for DictField with allow_null options (#4348)
This commit is contained in:
parent
bda16a518a
commit
5500b265bc
|
@ -1594,6 +1594,29 @@ class TestDictField(FieldValues):
|
|||
"Remove `source=` from the field declaration."
|
||||
)
|
||||
|
||||
def test_allow_null(self):
|
||||
"""
|
||||
If `allow_null=True` then `None` is a valid input.
|
||||
"""
|
||||
field = serializers.DictField(allow_null=True)
|
||||
output = field.run_validation(None)
|
||||
assert output is None
|
||||
|
||||
|
||||
class TestDictFieldWithNullChild(FieldValues):
|
||||
"""
|
||||
Values for `ListField` with allow_null CharField as child.
|
||||
"""
|
||||
valid_inputs = [
|
||||
({'a': None, 'b': '2', 3: 3}, {'a': None, 'b': '2', '3': '3'}),
|
||||
]
|
||||
invalid_inputs = [
|
||||
]
|
||||
outputs = [
|
||||
({'a': None, 'b': '2', 3: 3}, {'a': None, 'b': '2', '3': '3'}),
|
||||
]
|
||||
field = serializers.DictField(child=serializers.CharField(allow_null=True))
|
||||
|
||||
|
||||
class TestUnvalidatedDictField(FieldValues):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user