      def test_generator_cache(self):
          generator = ("{}".format(i) for i in range(10))
          response = HttpResponse(content=generator)
          self.assertEqual(response.content, b'0123456789')
          self.assertRaises(StopIteration, next, generator)
  
          cache.set('my-response-key', response)
          response = cache.get('my-response-key')
          self.assertEqual(response.content, b'0123456789')
 
</s> remove         self.assertRaises(ContentNotRenderedError,
                          pickle.dumps, response)
 </s> add         with self.assertRaises(ContentNotRenderedError):
            pickle.dumps(response) </s> remove         self.assertRaises(ContentNotRenderedError,
                          pickle.dumps, response)
 </s> add         with self.assertRaises(ContentNotRenderedError):
            pickle.dumps(response) </s> remove         self.assertRaises(ContentNotRenderedError, lambda: response.content)
 </s> add         with self.assertRaises(ContentNotRenderedError):
            response.content </s> remove         self.assertRaises(signing.BadSignature,
            request.get_signed_cookie, 'c')
 </s> add         with self.assertRaises(signing.BadSignature):
            request.get_signed_cookie('c') </s> remove         self.assertRaises(ContentNotRenderedError,
                          pickle.dumps, response)
 </s> add         with self.assertRaises(ContentNotRenderedError):
            pickle.dumps(response)
        with self.assertRaises(StopIteration):
            next(generator)
      def test_generator_cache(self):
          generator = ("{}".format(i) for i in range(10))
          response = HttpResponse(content=generator)
          self.assertEqual(response.content, b'0123456789')
        with self.assertRaises(StopIteration):
            next(generator)
  
          cache.set('my-response-key', response)
          response = cache.get('my-response-key')
          self.assertEqual(response.content, b'0123456789')
keep keep keep keep replace keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/responses/tests.py