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

@@ -75,11 +75,11 @@ class ValidationTests(SimpleTestCase):
f.clean("not a", None)
def test_enum_choices_cleans_valid_string(self):
f = models.CharField(choices=self.Choices.choices, max_length=1)
f = models.CharField(choices=self.Choices, max_length=1)
self.assertEqual(f.clean("c", None), "c")
def test_enum_choices_invalid_input(self):
f = models.CharField(choices=self.Choices.choices, max_length=1)
f = models.CharField(choices=self.Choices, max_length=1)
msg = "Value 'a' is not a valid choice."
with self.assertRaisesMessage(ValidationError, msg):
f.clean("a", None)