Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
5500b265
Commit
5500b265
authored
Aug 02, 2016
by
Tom Christie
Committed by
GitHub
Aug 02, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test cases for DictField with allow_null options (#4348)
parent
bda16a51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
tests/test_fields.py
+23
-0
No files found.
tests/test_fields.py
View file @
5500b265
...
@@ -1594,6 +1594,29 @@ class TestDictField(FieldValues):
...
@@ -1594,6 +1594,29 @@ class TestDictField(FieldValues):
"Remove `source=` from the field declaration."
"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
):
class
TestUnvalidatedDictField
(
FieldValues
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment