1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #34716 -- Fixed serialization of nested class methods in migrations.

Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
This commit is contained in:
Nicolò Intrieri 2023-07-18 05:27:40 +02:00 committed by GitHub
parent 4a72da7100
commit e8252fc445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -168,7 +168,7 @@ class FunctionTypeSerializer(BaseSerializer):
):
klass = self.value.__self__
module = klass.__module__
return "%s.%s.%s" % (module, klass.__name__, self.value.__name__), {
return "%s.%s.%s" % (module, klass.__qualname__, self.value.__name__), {
"import %s" % module
}
# Further error checking

View File

@ -211,6 +211,10 @@ class WriterTests(SimpleTestCase):
X = "X", "X value"
Y = "Y", "Y value"
@classmethod
def method(cls):
return cls.X
def safe_exec(self, string, value=None):
d = {}
try:
@ -468,6 +472,15 @@ class WriterTests(SimpleTestCase):
),
)
def test_serialize_nested_class_method(self):
self.assertSerializedResultEqual(
self.NestedChoices.method,
(
"migrations.test_writer.WriterTests.NestedChoices.method",
{"import migrations.test_writer"},
),
)
def test_serialize_uuid(self):
self.assertSerializedEqual(uuid.uuid1())
self.assertSerializedEqual(uuid.uuid4())