title: Unable to decode JSON body for Falcon tests in Python
body: <p>I'm trying to write some pytests for the Falcon framework and am following the instructions <a href="http://falcon.readthedocs.io/en/stable/api/testing.html" rel="nofollow noreferrer">here</a>. I want to simulate a POST request. However, I keep getting the following error    </p>
  
  <blockquote>
    <p>tests/test_app.py:29: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  ../../harvester-venv/lib/python2.7/site-packages/falcon/testing/client.py:170:
    in json
        return json.loads(self.text) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/<strong>init</strong>.py:338:
    in loads
        return _default_decoder.decode(s) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py:366:
    in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())</p>
    
    <hr>
    
    <p>self = , s = '', idx =
    0</p>
  
  <pre><code>def raw_decode(self, s, idx=0):
      """Decode a JSON document from ``s`` (a ``str`` or ``unicode``
          beginning with a JSON document) and return a 2-tuple of the Python
          representation and the index in ``s`` where the document ended.
  
          This can be used to decode a JSON document from a string that may
          have extraneous data at the end.
  
          """
      try:
          obj, end = self.scan_once(s, idx)
      except StopIteration:
  </code></pre>
    
    <blockquote>
  <pre><code>      raise ValueError("No JSON object could be decoded") E           ValueError: No JSON object could be decoded
  </code></pre>
    </blockquote>
    
    <p>/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py:384:
    ValueError</p>
  </blockquote>
  
  <p>Here is the Falcon test I am attempting to write. When I validate the JSON I put in the <code>data</code> variable on <a href="https://jsonlint.com/" rel="nofollow noreferrer">JSONlint.com</a> it shows me the data is valid so the issue doesn't seem to be with the formatting.</p>
  
  <pre><code>import json
  
  import pytest
  from falcon import testing
  
  from harvester.app import api
  
  
  @pytest.fixture()
  def client():
      return testing.TestClient(api)
  
  
  def test_elasticsearch_endpoint(client):
      data = {
          "Type": "SubscriptionConfirmation",
          "MessageId": "0a069ec4-2e6f-4436-9f1d-aa55c3b048f9",
          "Token": "2336412f37fb68751e6e241d59b68cb9ca332001818266bdd4984dd60a76ff2c8a43220b28241ad0ae6659d6313bb2336e98d19bdbc52e0c99578ad43934324b5e73a20e9ad517741cf14a57793d052e9986038ee688a059b34e49746d106bcd597f18f7ff3560be204ef8cd339a3c5276bfa3cc784a7904c8720519387a0",
          "TopicArn": "arn:aws:sns:ap-south-1:141592612890",
          "SubscribeURL": "https://sns.ap-south-1.amazonaws.com/?Action=ConfirmSubscription&amp;TopicArn=arn:aws:sns:ap-south-1:141592612890:harvester_test&amp;Token=2336412f37fb687f5d51e6e241d59b68cb9ca332001818266bdd4984dd60a76ff2c8a41ad0ae6659d6313bb2336e98d19bdbc52e0c99578ad43934324b5e73a20e9ad517741cf14a57793d052e9986038ee688a059b34e49746d106bcd597f18f7ff3560be204ef8cd339a3c5276bfa3cc784a7904c8720519387a0",
          "Timestamp": "2017-06-01T13:22:49.849Z",
          "SignatureVersion": "1",
          "Signature": "Pj9F8PrgqPkSuLjHtrJ9pmh3ZH3kZBaLs5Ywx1C0rrOc4PJp3hYiria9SZr1Xm8uE549khxDFIdAsnGee9fSeO7tZWSNI3W3gRLVnIJ0uAjxU0oicj3P7NnGQ5kUnihKva//Q39RlZOIr4OsxTvOrXnag6M32aC3pEFdBaXJqO0iJJOokT+mmoWa9BWfHXnb/ORAigo50BXsVNSN92PRZAZ7qTeypZSU70EF1+vKNt7mbxrOE2/wpOtb7uDfg/ZW8yZQQqr100bnQVfStDSp6MzID+vupQhM2PR/gS84INA+VdOUhxll/kEkDE98tR9OrNz/PITts5XSg==",
          "SigningCertURL": "https://sns.ap-south-1.amazonaws.com/SimpleNotificationService-b95095beb82e8f6a04.pem"
      }
      result = client.simulate_post('/v1/track/analytics', body=json.dumps(data))
      print result.json
  </code></pre>
  
  <p>Any clue why this occurs?</p>