aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_fields.py
diff options
context:
space:
mode:
authorTom Christie2014-12-09 14:08:45 +0000
committerTom Christie2014-12-09 14:08:45 +0000
commit54a18a4ddb69bb43c13e45f151b075564dd771b2 (patch)
treec392eb5c1afba4dee29d67c2e67411b957371bdf /tests/test_fields.py
parentcae19f8924c598cea93a546138757ff48eed9f75 (diff)
parentafe7ed9333e37384f8ddc57e891da9632c8714c3 (diff)
downloaddjango-rest-framework-54a18a4ddb69bb43c13e45f151b075564dd771b2.tar.bz2
Merge pull request #2239 from jpadilla/allow-blank-choicefield
Add allow_blank for ChoiceField #2184
Diffstat (limited to 'tests/test_fields.py')
-rw-r--r--tests/test_fields.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_fields.py b/tests/test_fields.py
index 13525632..3f4e65f2 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -804,6 +804,21 @@ class TestChoiceField(FieldValues):
]
)
+ def test_allow_blank(self):
+ """
+ If `allow_blank=True` then '' is a valid input.
+ """
+ field = serializers.ChoiceField(
+ allow_blank=True,
+ choices=[
+ ('poor', 'Poor quality'),
+ ('medium', 'Medium quality'),
+ ('good', 'Good quality'),
+ ]
+ )
+ output = field.run_validation('')
+ assert output is ''
+
class TestChoiceFieldWithType(FieldValues):
"""