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:
parent
4a72da7100
commit
e8252fc445
@ -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
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user