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:
committed by
Mariusz Felisiak
parent
051d5944f8
commit
a2eaea8f22
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user