1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #35241 -- Cached model's full parent list.

co-authored-by: Keryn Knight <keryn@kerynknight.com>
co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
co-authored-by: David Smith <smithdc@gmail.com>
co-authored-by: Paolo Melchiorre <paolo@melchiorre.org>
This commit is contained in:
Adam Johnson
2024-02-23 22:50:09 +00:00
committed by Mariusz Felisiak
parent 6e1ece7ed5
commit 73d5eb8084
10 changed files with 41 additions and 33 deletions

View File

@@ -325,15 +325,19 @@ class RelationTreeTests(SimpleTestCase):
)
class ParentListTests(SimpleTestCase):
def test_get_parent_list(self):
self.assertEqual(CommonAncestor._meta.get_parent_list(), [])
self.assertEqual(FirstParent._meta.get_parent_list(), [CommonAncestor])
self.assertEqual(SecondParent._meta.get_parent_list(), [CommonAncestor])
class AllParentsTests(SimpleTestCase):
def test_all_parents(self):
self.assertEqual(CommonAncestor._meta.all_parents, ())
self.assertEqual(FirstParent._meta.all_parents, (CommonAncestor,))
self.assertEqual(SecondParent._meta.all_parents, (CommonAncestor,))
self.assertEqual(
Child._meta.get_parent_list(), [FirstParent, SecondParent, CommonAncestor]
Child._meta.all_parents,
(FirstParent, SecondParent, CommonAncestor),
)
def test_get_parent_list(self):
self.assertEqual(Child._meta.get_parent_list(), list(Child._meta.all_parents))
class PropertyNamesTests(SimpleTestCase):
def test_person(self):