              label_for_field("__str__", Article),
              str("article")
          )
  
          self.assertRaises(
              AttributeError,
              lambda: label_for_field("unknown", Article)
          )
  
          def test_callable(obj):
              return "nothing"
          self.assertEqual(
              label_for_field(test_callable, Article),
 
</s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().annotate(num_authors=Count('authors__id')).aggregate(Max('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().annotate(num_authors=Count('authors__id')).aggregate(Max('foo')) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.annotate(mean_age=Avg('authors__age')).annotate(Avg('mean_age'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.annotate(mean_age=Avg('authors__age')).annotate(Avg('mean_age')) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().annotate(num_authors=Count('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().annotate(num_authors=Count('foo')) </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().aggregate(num_authors=Count('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().aggregate(num_authors=Count('foo')) </s> remove         self.assertRaises(
            FieldError,
            lambda: Author.objects.filter(firstname__exact="John")
        )
 </s> add         with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
        with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
              label_for_field("__str__", Article),
              str("article")
          )
  
        with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
        with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
        with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
        with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
  
          def test_callable(obj):
              return "nothing"
          self.assertEqual(
              label_for_field(test_callable, Article),
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/admin_utils/tests.py