'When intermediary results are prefetched without a destination
attribute, they are saved in the RelatedManager\'s cache
(_prefetched_objects_cache). prefetch_related() uses this cache
(#27554).'

def test_retrieves_results_from_prefetched_objects_cache(self):

    authors = AuthorWithAge.objects.prefetch_related(Prefetch('author', queryset=Author.objects.prefetch_related(Prefetch('favorite_authors__first_book'))))
    with self.assertNumQueries(4):
        self.assertQuerysetEqual(authors, ['<AuthorWithAge:    Rousseau>', '<AuthorWithAge:    Voltaire>'])
