

def test_num_queries(self):
    with translation.override('en'):
        en = Normal.objects.language('en').get(pk=self.normal_id[1])
        with self.assertNumQueries(1):
            related = Standard.objects.select_related('normal').get(pk=self.standard_id[1])
            self.assertEqual(related.normal.pk, en.pk)
        with self.assertNumQueries(0):
            self.assertEqual(related.normal.shared_field, en.shared_field)
        with self.assertNumQueries(1):
            self.assertEqual(related.normal.translated_field, en.translated_field)

dataset/ETHPy150Open KristianOellegaard/django-hvad/hvad/tests/related.py StandardToTransFKTest.test_num_queries/original