]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
add test from @mbachry empty_response_body
authorKevin McCarthy <me@kevinmccarthy.org>
Sun, 2 Oct 2016 20:24:19 +0000 (10:24 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 2 Oct 2016 20:24:38 +0000 (10:24 -1000)
tests/integration/test_requests.py

index 84a992b638e2ee8844b6af167f5d8fd0dfd9588d..804ab2e3f348eed631889ee9079d245952eb5f38 100644 (file)
@@ -38,6 +38,18 @@ def test_body(tmpdir, httpbin_both):
         assert content == requests.get(url).content
 
 
+def test_get_empty_content_type_json(tmpdir, httpbin_both):
+    '''Ensure GET with application/json content-type and empty request body doesn't crash'''
+    url = httpbin_both + '/status/200'
+    headers = {'Content-Type': 'application/json'}
+
+    with vcr.use_cassette(str(tmpdir.join('get_empty_json.yaml')), match_on=('body',)):
+        status = requests.get(url, headers=headers).status_code
+
+    with vcr.use_cassette(str(tmpdir.join('get_empty_json.yaml')), match_on=('body',)):
+        assert status == requests.get(url, headers=headers).status_code
+
+
 def test_effective_url(tmpdir, httpbin_both):
     '''Ensure that the effective_url is captured'''
     url = httpbin_both.url + '/redirect-to?url=/html'