1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #31262 -- Added support for mappings on model fields and ChoiceField's choices.

This commit is contained in:
Nick Pope
2023-08-31 02:57:40 +01:00
committed by GitHub
parent 68a8996bdf
commit 500e01073a
29 changed files with 822 additions and 249 deletions

View File

@@ -279,6 +279,14 @@ class ValidationTests(SimpleTestCase):
f = models.IntegerField(choices=(("group", ((10, "A"), (20, "B"))), (30, "C")))
self.assertEqual(10, f.clean(10, None))
def test_choices_validation_supports_named_groups_dicts(self):
f = models.IntegerField(choices={"group": ((10, "A"), (20, "B")), 30: "C"})
self.assertEqual(10, f.clean(10, None))
def test_choices_validation_supports_named_groups_nested_dicts(self):
f = models.IntegerField(choices={"group": {10: "A", 20: "B"}, 30: "C"})
self.assertEqual(10, f.clean(10, None))
def test_nullable_integerfield_raises_error_with_blank_false(self):
f = models.IntegerField(null=True, blank=False)
with self.assertRaises(ValidationError):