def test_get_choices(self): """Overridden get_choices suppresses blank choice tuple""" item = SelectMultipleField(choices=self.choices) choices = item.get_choices() self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertNotIn(BLANK_CHOICE_DASH[0], choices) choices = item.get_choices(include_blank=False) self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertNotIn(BLANK_CHOICE_DASH[0], choices)
def test_get_choices_include_blank(self): """ Explicit include_blank value is honored, ignoring passed parameters """ item = SelectMultipleField(choices=self.choices, include_blank=True) choices = item.get_choices() self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertIn(BLANK_CHOICE_DASH[0], choices) choices = item.get_choices(include_blank=False) self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertIn(BLANK_CHOICE_DASH[0], choices) item = SelectMultipleField(choices=self.choices, include_blank=False) choices = item.get_choices() self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertNotIn(BLANK_CHOICE_DASH[0], choices) choices = item.get_choices(include_blank=True) self.assertIsInstance(choices, list) self.assertIsInstance(choices[0], tuple) self.assertNotIn(BLANK_CHOICE_DASH[0], choices)