              six.text_type
          )
  
      def test_field_error(self):
          self.assertRaises(
              FieldError,
              lambda: Author.objects.filter(firstname__exact="John")
          )
  
      def test_attribute_error(self):
          with self.assertRaises(AttributeError):
              self.a1.firstname
  
 
</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: 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().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(
            TypeError,
            Article.objects.dates,
        )
 </s> add         with self.assertRaises(TypeError):
            Article.objects.dates() </s> remove         self.assertRaises(
            AttributeError,
            lambda: label_for_field("unknown", Article)
        )
 </s> add         with self.assertRaises(AttributeError):
            label_for_field("unknown", Article)
        with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
              six.text_type
          )
  
      def test_field_error(self):
        with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
        with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
        with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
        with self.assertRaises(FieldError):
            Author.objects.filter(firstname__exact="John")
  
      def test_attribute_error(self):
          with self.assertRaises(AttributeError):
              self.a1.firstname
  
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/custom_columns/tests.py