  
      def test_reverse_relation_name_conflict(self):
          # Regression for #11256 - providing an aggregate name
          # that conflicts with a reverse-related name on the model raises ValueError
          self.assertRaises(ValueError, Author.objects.annotate, book_contact_set=Avg('friends__age'))
  
      def test_pickle(self):
          # Regression for #10197 -- Queries with aggregates can be pickled.
          # First check that pickling is possible at all. No crash = success
          qs = Book.objects.annotate(num_authors=Count('authors'))
 
</s> remove         self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(age=Avg('friends__age')) </s> remove         self.assertRaises(
            ValueError,
            Book.objects.all().annotate,
            Avg('authors__age'), authors__age__avg=Avg('authors__age')
        )
 </s> add         with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age')) </s> remove         self.assertRaises(ValueError, Author.objects.annotate, friends=Count('friends'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(friends=Count('friends')) </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(AssertionError, Person.objects.latest)
 </s> add         with self.assertRaises(AssertionError):
            Person.objects.latest()
        with self.assertRaises(ValueError):
            Author.objects.annotate(book_contact_set=Avg('friends__age'))
  
      def test_reverse_relation_name_conflict(self):
          # Regression for #11256 - providing an aggregate name
          # that conflicts with a reverse-related name on the model raises ValueError
        with self.assertRaises(ValueError):
            Author.objects.annotate(book_contact_set=Avg('friends__age'))
  
      def test_pickle(self):
          # Regression for #10197 -- Queries with aggregates can be pickled.
          # First check that pickling is possible at all. No crash = success
          qs = Book.objects.annotate(num_authors=Count('authors'))
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/aggregation_regress/tests.py