summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2020-09-09 12:26:34 +0200
committerCarlton Gibson <carlton@noumenal.es>2020-09-10 11:42:06 +0200
commit1db8d8e3a9264eb38e8d0e0d515f598db7520ce6 (patch)
tree2cec2dbd72800d063de130b3c3bc7e0b3aef78ae /tests/model_fields
parent438b85dfab4f16a2e709e2bcdbfefecd7bfee89e (diff)
downloaddjango-1db8d8e3a9264eb38e8d0e0d515f598db7520ce6.tar.gz
Refs #23130 -- Added test for BooleanField choices generation.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_booleanfield.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/model_fields/test_booleanfield.py b/tests/model_fields/test_booleanfield.py
index 72c9293d93..89e0ecfa2a 100644
--- a/tests/model_fields/test_booleanfield.py
+++ b/tests/model_fields/test_booleanfield.py
@@ -47,6 +47,15 @@ class BooleanFieldTests(TestCase):
f = models.BooleanField(choices=choices, default=1, null=False)
self.assertEqual(f.formfield().choices, choices)
+ def test_booleanfield_choices_blank_desired(self):
+ """
+ BooleanField with choices and no default should generated a formfield
+ with the blank option.
+ """
+ choices = [(1, 'Si'), (2, 'No')]
+ f = models.BooleanField(choices=choices)
+ self.assertEqual(f.formfield().choices, [('', '---------')] + choices)
+
def test_nullbooleanfield_formfield(self):
f = models.BooleanField(null=True)
self.assertIsInstance(f.formfield(), forms.NullBooleanField)