From 500e01073adda32d5149624ee9a5cb7aa3d3583f Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Thu, 31 Aug 2023 02:57:40 +0100 Subject: Fixed #31262 -- Added support for mappings on model fields and ChoiceField's choices. --- tests/model_fields/test_integerfield.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/model_fields/test_integerfield.py') diff --git a/tests/model_fields/test_integerfield.py b/tests/model_fields/test_integerfield.py index 6761589b7e..0d91cff9eb 100644 --- a/tests/model_fields/test_integerfield.py +++ b/tests/model_fields/test_integerfield.py @@ -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): -- cgit v1.3