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:
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user