diff options
| author | John Bowen <jbowen7@gmail.com> | 2019-11-22 12:43:03 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-25 11:27:15 +0100 |
| commit | b6cbc88f26aa7a4279a71cd8895dc0a1aa6ff398 (patch) | |
| tree | 1acd545163e06a65f8cf66838623c661cb3c37c9 /tests | |
| parent | ba5760965ed52d1b310097e060f8511f9bad7631 (diff) | |
[3.0.x] Fixed #27914 -- Fixed serialization of nested classes in migrations.
Backport of 29d8198841ea39af44f3bc835d646e642d498475 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_writer.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index addf10b0f0..6a65e87d5a 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -193,6 +193,10 @@ class WriterTests(SimpleTestCase): A = 1 B = 2 + class NestedChoices(models.TextChoices): + X = 'X', 'X value' + Y = 'Y', 'Y value' + def safe_exec(self, string, value=None): d = {} try: @@ -388,6 +392,18 @@ class WriterTests(SimpleTestCase): "default=datetime.date(1969, 11, 19))" ) + def test_serialize_nested_class(self): + for nested_cls in [self.NestedEnum, self.NestedChoices]: + cls_name = nested_cls.__name__ + with self.subTest(cls_name): + self.assertSerializedResultEqual( + nested_cls, + ( + "migrations.test_writer.WriterTests.%s" % cls_name, + {'import migrations.test_writer'}, + ), + ) + def test_serialize_uuid(self): self.assertSerializedEqual(uuid.uuid1()) self.assertSerializedEqual(uuid.uuid4()) |
