From 73d5eb808435bcf27ebc935847196ac9e97b6ddc Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 23 Feb 2024 22:50:09 +0000 Subject: Fixed #35241 -- Cached model's full parent list. co-authored-by: Keryn Knight co-authored-by: Natalia <124304+nessita@users.noreply.github.com> co-authored-by: David Smith co-authored-by: Paolo Melchiorre --- tests/model_meta/tests.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/model_meta/tests.py b/tests/model_meta/tests.py index fef82661cd..0aa04d760d 100644 --- a/tests/model_meta/tests.py +++ b/tests/model_meta/tests.py @@ -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): -- cgit v1.3