1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +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

@@ -301,11 +301,11 @@ class ValidationTests(SimpleTestCase):
f.clean("0", None)
def test_enum_choices_cleans_valid_string(self):
f = models.IntegerField(choices=self.Choices.choices)
f = models.IntegerField(choices=self.Choices)
self.assertEqual(f.clean("1", None), 1)
def test_enum_choices_invalid_input(self):
f = models.IntegerField(choices=self.Choices.choices)
f = models.IntegerField(choices=self.Choices)
with self.assertRaises(ValidationError):
f.clean("A", None)
with self.assertRaises(ValidationError):