

def test_prefetch_translations(self):
    article = self.articles[0]
    with self.assertNumQueries(1):
        article.prefetch_translations()
    with self.assertNumQueries(0):
        for language in ('fr', 'en'):
            title = getattr(article, ('title_%s' % language))
    article.clear_translations_cache()
    article.author.clear_translations_cache()
    with self.assertNumQueries(2):
        article.prefetch_translations('author')
    with self.assertNumQueries(0):
        for language in ('fr', 'en'):
            title = getattr(article, ('title_%s' % language))
            author_bio = getattr(article.author, ('bio_%s' % language))

dataset/ETHPy150Open ulule/django-linguist/linguist/tests/test_model_mixin.py ModelMixinTest.test_prefetch_translations/original