          self.assertTrue(p.has_next())
          self.assertFalse(p.has_previous())
          self.assertTrue(p.has_other_pages())
          self.assertEqual(2, p.next_page_number())
          self.assertRaises(InvalidPage, p.previous_page_number)
          self.assertEqual(1, p.start_index())
          self.assertEqual(5, p.end_index())
  
      def test_last_page(self):
          paginator = Paginator(Article.objects.all(), 5)
 
</s> remove         self.assertRaises(InvalidPage, p.next_page_number)
 </s> add         with self.assertRaises(InvalidPage):
            p.next_page_number() </s> remove         self.assertRaises(InvalidPage, paginator.page, 3)
        self.assertRaises(PageNotAnInteger, paginator.validate_number, None)
        self.assertRaises(PageNotAnInteger, paginator.validate_number, 'x')
 </s> add         with self.assertRaises(InvalidPage):
            paginator.page(3)
        with self.assertRaises(PageNotAnInteger):
            paginator.validate_number(None)
        with self.assertRaises(PageNotAnInteger):
            paginator.validate_number('x') </s> remove         self.assertRaises(ValidationError, f.clean, "a", None)
 </s> add         with self.assertRaises(ValidationError):
            f.clean("a", None) </s> remove         except ValidationError as e:
            self.assertEqual(2, len(e.messages))
 </s> add         self.assertEqual(2, len(e.exception.messages)) </s> remove             self.assertRaises(TypeError, lm.save, fid_range=bad)
 </s> add             with self.assertRaises(TypeError):
                lm.save(fid_range=bad)
        with self.assertRaises(InvalidPage):
            p.previous_page_number()
          self.assertTrue(p.has_next())
          self.assertFalse(p.has_previous())
          self.assertTrue(p.has_other_pages())
          self.assertEqual(2, p.next_page_number())
        with self.assertRaises(InvalidPage):
            p.previous_page_number()
          self.assertEqual(1, p.start_index())
          self.assertEqual(5, p.end_index())
  
      def test_last_page(self):
          paginator = Paginator(Article.objects.all(), 5)
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/pagination/tests.py