title: Python nose test failing on JSON response
body: <p>This is the method in ReportRunner class in report_runner.py in my Flask-Restful app:</p>
  
  <pre><code>class ReportRunner(object):
  
    def __init__(self):
          pass
  
    def setup_routes(self, app):
        app.add_url_rule("/run_report", view_func=self.run_report)
  
    def request_report(self, key):
      # code #
  
    def key_exists(self, key):
      # code #
  
    def run_report(self):
      key = request.args.get("key", "")
      if self.key_exists(key):
        self.request_report(report_type, key)
        return jsonify(message = "Success! Your report has been created.")
      else:
        response = jsonify({"message": "Error =&gt; report key not found on server."})
        response.status_code = 404
        return response
  </code></pre>
  
  <p>and the nose test calls the URL associated with that route</p>
  
  <pre><code>def setUp(self):
      self.setup_flask()
      self.controller = Controller()
      self.report_runner = ReportRunner()
      self.setup_route(self.report_runner)
  
  def test_run_report(self):
      rr = Report(key = "daily_report")
      rr.save()
      self.controller.override(self.report_runner, "request_report")
      self.controller.expectAndReturn(self.report_runner.request_report("daily_report"), True )
      self.controller.replay()
      response = self.client.get("/run_report?key=daily_report")
      assert_equals({"message": "Success! Your report has been created."}, response.json)
      assert_equals(200, response.status_code)
  </code></pre>
  
  <p>and the test was failing with the following message:</p>
  
  <pre><code>AttributeError: 'Response' object has no attribute 'json'
  </code></pre>
  
  <p>but according to the <a href="https://flask-testing.readthedocs.org/en/latest/" rel="nofollow">docs</a> it seems that this is how you do it. Do I change the return value from the method, or do I need to structure the test differently?</p>
  
  <p>The test is now passing written like this:</p>
  
  <pre><code>json_response = json.loads(response.data)
  assert_equals("Success! Your report has been created.", json_response["message"])
  </code></pre>
  
  <p>but I'm not clear on the difference between the two approaches.</p>