コード例 #1
0
 def test_formfield_default_is_callable(self):
     item = SelectMultipleField(default=FakeCallableDefault)
     form = item.formfield()
     self.assertIsInstance(form, SelectMultipleFormField)
     self.assertTrue(item.has_default())
     self.assertTrue(callable(form.initial))
     self.assertIs(form.initial, FakeCallableDefault)
コード例 #2
0
 def test_formfield_default_string(self):
     string_default = "String As Default"
     item = SelectMultipleField(default=string_default)
     form = item.formfield()
     self.assertIsInstance(form, SelectMultipleFormField)
     self.assertTrue(item.has_default())
     self.assertEqual(item.get_default(), string_default)
     self.assertEqual(form.initial, string_default)
コード例 #3
0
 def test_formfield_no_empty_value_by_default(self):
     """
     Formfield returns no empty value by default
     """
     item = SelectMultipleField(choices=self.choices)
     form = item.formfield()
     self.assertIsInstance(form, SelectMultipleFormField)
     self.assertFalse(item.has_default())
     self.assertEqual(form.coerce, item.to_python)
     self.assertFalse(item.blank)
     self.assertTrue(form.required)
     self.assertFalse(item.null)
     self.assertEqual(form.empty_value, [])
     self.assertNotIn(BLANK_CHOICE_DASH[0], form.choices)