  
          def iteration():
              for x in response:
                  pass
          self.assertRaises(ContentNotRenderedError, iteration)
          self.assertFalse(response.is_rendered)
  
      def test_iteration_rendered(self):
          # iteration works for rendered responses
          response = self._response().render()
 
</s> remove         self.assertRaises(ContentNotRenderedError, lambda: response.content)
 </s> add         with self.assertRaises(ContentNotRenderedError):
            response.content </s> remove         self.assertRaises(StopIteration, next, generator)
 </s> add         with self.assertRaises(StopIteration):
            next(generator) </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) </s> remove             self.assertRaises(e, qs.count)
 </s> add             with self.assertRaises(e):
                qs.count() </s> remove             self.assertRaises(SuspiciousOperation,
                              HttpResponseRedirect, url)
            self.assertRaises(SuspiciousOperation,
                              HttpResponsePermanentRedirect, url)
 </s> add             with self.assertRaises(SuspiciousOperation):
                HttpResponseRedirect(url)
            with self.assertRaises(SuspiciousOperation):
                HttpResponsePermanentRedirect(url)
        with self.assertRaises(ContentNotRenderedError):
            iteration()
  
          def iteration():
              for x in response:
                  pass
        with self.assertRaises(ContentNotRenderedError):
            iteration()
          self.assertFalse(response.is_rendered)
  
      def test_iteration_rendered(self):
          # iteration works for rendered responses
          response = self._response().render()
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/template_tests/test_response.py