          )
          self.assertFalse(p.has_next())
          self.assertTrue(p.has_previous())
          self.assertTrue(p.has_other_pages())
          self.assertRaises(InvalidPage, p.next_page_number)
          self.assertEqual(1, p.previous_page_number())
          self.assertEqual(6, p.start_index())
          self.assertEqual(9, p.end_index())
  
      def test_page_getitem(self):
 
</s> remove         self.assertRaises(InvalidPage, p.previous_page_number)
 </s> add         with self.assertRaises(InvalidPage):
            p.previous_page_number() </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(
            TypeError,
            Article.objects.dates,
        )
 </s> add         with self.assertRaises(TypeError):
            Article.objects.dates() </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(admin.sites.AlreadyRegistered,
                          self.site.register,
                          Person)
 </s> add         with self.assertRaises(admin.sites.AlreadyRegistered):
            self.site.register(Person)
        with self.assertRaises(InvalidPage):
            p.next_page_number()
          )
          self.assertFalse(p.has_next())
          self.assertTrue(p.has_previous())
          self.assertTrue(p.has_other_pages())
        with self.assertRaises(InvalidPage):
            p.next_page_number()
          self.assertEqual(1, p.previous_page_number())
          self.assertEqual(6, p.start_index())
          self.assertEqual(9, p.end_index())
  
      def test_page_getitem(self):
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/pagination/tests.py