def test_empty_ok(self): field = ChoiceOrCharField(choices=enumerate(self._team, start=1), required=False) with self.assertNoException(): cleaned = field.clean(['', '']) self.assertEqual((None, None), cleaned)
def test_ok_other(self): field = ChoiceOrCharField(choices=enumerate(self._team, start=1)) with self.assertNoException(): choices = field.choices self.assertIn((0, _('Other')), choices) other = 'Shikamaru' self.assertEqual((0, other), field.clean([0, other]))
def test_ok_choice(self): field = ChoiceOrCharField(choices=enumerate(self._team, start=1)) self.assertEqual((1, 'Naruto'), field.clean([1, '']))