          self.assertEqual(qstr[qstr.index('GROUP BY'):].count(', '), 0)
  
      def test_duplicate_alias(self):
          # Regression for #11256 - duplicating a default alias raises ValueError.
          self.assertRaises(
              ValueError,
              Book.objects.all().annotate,
              Avg('authors__age'), authors__age__avg=Avg('authors__age')
          )
  
      def test_field_name_conflict(self):
          # Regression for #11256 - providing an aggregate name
          # that conflicts with a field name on the model raises ValueError
          self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))
 
</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, Author.objects.annotate, friends=Count('friends'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(friends=Count('friends')) </s> remove         self.assertRaises(ValueError, Author.objects.annotate, book_contact_set=Avg('friends__age'))
 </s> add         with self.assertRaises(ValueError):
            Author.objects.annotate(book_contact_set=Avg('friends__age')) </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, list, qs)
        self.assertRaises(FieldError, list, qs)
 </s> add         with self.assertRaises(FieldError):
            list(qs)
        with self.assertRaises(FieldError):
            list(qs)
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
          self.assertEqual(qstr[qstr.index('GROUP BY'):].count(', '), 0)
  
      def test_duplicate_alias(self):
          # Regression for #11256 - duplicating a default alias raises ValueError.
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
        with self.assertRaises(ValueError):
            Book.objects.all().annotate(Avg('authors__age'), authors__age__avg=Avg('authors__age'))
  
      def test_field_name_conflict(self):
          # Regression for #11256 - providing an aggregate name
          # that conflicts with a field name on the model raises ValueError
          self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/aggregation_regress/tests.py