Refs #23130 -- Added test for BooleanField choices generation.
This commit is contained in:
parent
438b85dfab
commit
1db8d8e3a9
|
@ -47,6 +47,15 @@ class BooleanFieldTests(TestCase):
|
||||||
f = models.BooleanField(choices=choices, default=1, null=False)
|
f = models.BooleanField(choices=choices, default=1, null=False)
|
||||||
self.assertEqual(f.formfield().choices, choices)
|
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):
|
def test_nullbooleanfield_formfield(self):
|
||||||
f = models.BooleanField(null=True)
|
f = models.BooleanField(null=True)
|
||||||
self.assertIsInstance(f.formfield(), forms.NullBooleanField)
|
self.assertIsInstance(f.formfield(), forms.NullBooleanField)
|
||||||
|
|
Loading…
Reference in New Issue