def test_blank_choice(self): blank = ("", "---------") form = forms.PersonForm() self.assertEqual(form.fields["country"].choices[0], blank) multi_form = forms.MultiCountryForm() self.assertNotEqual(multi_form.fields["countries"].choices[0], blank)
def test_blank_choice(self): blank = ('', '---------') form = forms.PersonForm() self.assertEqual(form.fields['country'].choices[0], blank) multi_form = forms.MultiCountryForm() self.assertNotEqual(multi_form.fields['countries'].choices[0], blank)
def test_translated_choices(self): lang = translation.get_language() translation.activate("eo") form = forms.PersonForm() try: # This is just to prove that the language changed. self.assertEqual(list(countries)[0][1], "Afganio") # If the choices aren't lazy, this wouldn't be translated. It's the # second choice because the first one is the initial blank option. self.assertEqual(form.fields["country"].choices[1][1], "Afganio") self.assertEqual(form.fields["country"].widget.choices[1][1], "Afganio") finally: translation.activate(lang)
def test_no_blank_choice(self): form = forms.PersonForm() self.assertEqual(form.fields["favourite_country"].choices[0], ("AF", "Afghanistan"))
def test_no_blank_choice(self): form = forms.PersonForm() self.assertEqual(form.fields['favourite_country'].choices[0], ('AF', 'Afghanistan'))
def test_blank_choice(self): form = forms.PersonForm() self.assertEqual(form.fields['country'].choices[0], ('', '---------'))