1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #34388 -- Allowed using choice enumeration types directly on model and form fields.

This commit is contained in:
T. Franzel
2023-03-11 00:34:13 +01:00
committed by Mariusz Felisiak
parent 051d5944f8
commit a2eaea8f22
12 changed files with 48 additions and 19 deletions

View File

@@ -156,6 +156,7 @@ class ChoicesTests(SimpleTestCase):
cls.empty_choices_bool = Choiceful._meta.get_field("empty_choices_bool")
cls.empty_choices_text = Choiceful._meta.get_field("empty_choices_text")
cls.with_choices = Choiceful._meta.get_field("with_choices")
cls.choices_from_enum = Choiceful._meta.get_field("choices_from_enum")
def test_choices(self):
self.assertIsNone(self.no_choices.choices)
@@ -192,6 +193,10 @@ class ChoicesTests(SimpleTestCase):
with self.subTest(field=field):
self.assertIsInstance(field.formfield(), forms.ChoiceField)
def test_choices_from_enum(self):
# Choices class was transparently resolved when given as argument.
self.assertEqual(self.choices_from_enum.choices, Choiceful.Suit.choices)
class GetFieldDisplayTests(SimpleTestCase):
def test_choices_and_field_display(self):