              lambda d: d,
          )
  
      def test_dates_fails_when_no_arguments_are_provided(self):
          self.assertRaises(
              TypeError,
              Article.objects.dates,
          )
  
      def test_dates_fails_when_given_invalid_field_argument(self):
          six.assertRaisesRegex(
              self,
              FieldError,
 
</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") </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(
            ObjectDoesNotExist,
            Article.objects.get,
            pub_date__year=2005,
            pub_date__month=8,
        )
 </s> add         with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(TypeError):
            Article.objects.dates()
              lambda d: d,
          )
  
      def test_dates_fails_when_no_arguments_are_provided(self):
        with self.assertRaises(TypeError):
            Article.objects.dates()
        with self.assertRaises(TypeError):
            Article.objects.dates()
        with self.assertRaises(TypeError):
            Article.objects.dates()
        with self.assertRaises(TypeError):
            Article.objects.dates()
  
      def test_dates_fails_when_given_invalid_field_argument(self):
          six.assertRaisesRegex(
              self,
              FieldError,
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/dates/tests.py