def assertResponse(self,
                     expected_status,
                     expected_headers,
                     expected_content,
                     fn,
                     *args,
                     **kwargs):
    """Calls fn(*args, <start_response>, **kwargs) and checks the result.

    Args:
      expected_status: The expected HTTP status returned e.g. '200 OK'.
      expected_headers: A dict, list or wsgiref.headers.Headers representing the
          expected generated HTTP headers e.g. {'Content-type': 'text/plain'}.
      expected_content: The expected content generated e.g. 'Hello World'.
      fn: The function to test. This function will be called with
          fn(*args, start_response=<func>, **kwargs) where the start_response
          function verifies that it is called with the correct status and
          headers.
      *args: The positional arguments passed to fn.
      **kwargs: The keyword arguments passed to fn.
    """

    # Buffer for 'write' callable
    write_buffer = cStringIO.StringIO()

    def start_response(status, headers, exc_info=None):
      self.assertEqual(expected_status, status)
      self.assertHeadersEqual(expected_headers, headers)
      self.assertEqual(None, exc_info)
      return write_buffer.write

    args += (start_response,)
    response = fn(*args, **kwargs)
    # We sometimes use a function that might, but should not, return None
    # (URLHandler.handle_authorization). Explicitly test for this to avoid a
    # confusing TypeError on the following line.
    self.assertNotEqual(None, response, '%r(*args, **kwargs) != None' % fn)
    response = ''.join(response)
    self.assertIsInstance(
        response, str, 'response %r must be a str' % response[:10])
    self.assertMultiLineEqual(expected_content,
                              write_buffer.getvalue() + response)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/wsgi_test_utils.py/WSGITestCase.assertResponse/original