  
          # Make sure object_list queryset is not evaluated by an invalid __getitem__ call.
          # (this happens from the template engine when using eg: {% page_obj.has_previous %})
          self.assertIsNone(p.object_list._result_cache)
          self.assertRaises(TypeError, lambda: p['has_previous'])
          self.assertIsNone(p.object_list._result_cache)
          self.assertNotIsInstance(p.object_list, list)
  
          # Make sure slicing the Page object with numbers and slice objects work.
          self.assertEqual(p[0], Article.objects.get(headline='Article 1'))
 
</s> remove         self.assertRaises(TemplateDoesNotExist, self.client.get, '/render_no_template/')
 </s> add         with self.assertRaises(TemplateDoesNotExist):
            self.client.get('/render_no_template/') </s> remove         self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)
 </s> add         with self.assertRaises(ObjectDoesNotExist):
            Site.objects.get_current() </s> remove         self.assertRaises(ImproperlyConfigured, self.backend)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            self.backend() </s> remove         self.assertRaises(DatabaseError, self.column_classes, new_field.remote_field.through)
 </s> add         with self.assertRaises(DatabaseError):
            self.column_classes(new_field.remote_field.through) </s> remove         self.assertRaises(ImproperlyConfigured, Sitemap().get_urls)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            Sitemap().get_urls()
        with self.assertRaises(TypeError):
            p['has_previous']
  
          # Make sure object_list queryset is not evaluated by an invalid __getitem__ call.
          # (this happens from the template engine when using eg: {% page_obj.has_previous %})
          self.assertIsNone(p.object_list._result_cache)
        with self.assertRaises(TypeError):
            p['has_previous']
          self.assertIsNone(p.object_list._result_cache)
          self.assertNotIsInstance(p.object_list, list)
  
          # Make sure slicing the Page object with numbers and slice objects work.
          self.assertEqual(p[0], Article.objects.get(headline='Article 1'))
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/pagination/tests.py