(self)
| 786 | self.assertEqual(lst1, lst2) |
| 787 | |
| 788 | def test_generic_rel(self): |
| 789 | bookmark = Bookmark.objects.create(url="http://www.djangoproject.com/") |
| 790 | TaggedItem.objects.create(content_object=bookmark, tag="django") |
| 791 | TaggedItem.objects.create( |
| 792 | content_object=bookmark, favorite=bookmark, tag="python" |
| 793 | ) |
| 794 | |
| 795 | # Control lookups. |
| 796 | with self.assertNumQueries(4): |
| 797 | lst1 = self.traverse_qs( |
| 798 | Bookmark.objects.prefetch_related( |
| 799 | "tags", "tags__content_object", "favorite_tags" |
| 800 | ), |
| 801 | [["tags", "content_object"], ["favorite_tags"]], |
| 802 | ) |
| 803 | |
| 804 | # Test lookups. |
| 805 | with self.assertNumQueries(4): |
| 806 | lst2 = self.traverse_qs( |
| 807 | Bookmark.objects.prefetch_related( |
| 808 | Prefetch("tags", to_attr="tags_lst"), |
| 809 | Prefetch("tags_lst__content_object"), |
| 810 | Prefetch("favorite_tags"), |
| 811 | ), |
| 812 | [["tags_lst", "content_object"], ["favorite_tags"]], |
| 813 | ) |
| 814 | self.assertEqual(lst1, lst2) |
| 815 | |
| 816 | def test_traverse_single_item_property(self): |
| 817 | # Control lookups. |
nothing calls this directly
no test coverage detected