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

@@ -460,6 +460,16 @@ class WriterTests(SimpleTestCase):
"default=datetime.date(1969, 11, 19))",
)
def test_serialize_dictionary_choices(self):
for choices in ({"Group": [(2, "2"), (1, "1")]}, {"Group": {2: "2", 1: "1"}}):
with self.subTest(choices):
field = models.IntegerField(choices=choices)
string = MigrationWriter.serialize(field)[0]
self.assertEqual(
string,
"models.IntegerField(choices=[('Group', [(2, '2'), (1, '1')])])",
)
def test_serialize_nested_class(self):
for nested_cls in [self.NestedEnum, self.NestedChoices]:
cls_name = nested_cls.__name__