Skip to content

Commit

Permalink
test_aiohttpparser: Add a test to ensure correct behaviour on empty J…
Browse files Browse the repository at this point in the history
…SON bodies
  • Loading branch information
Fadi Moukayed committed Oct 23, 2018
1 parent c0cee7d commit 7454c35
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_aiohttpparser.py
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-

import asyncio
import webtest
import webtest_aiohttp
import pytest

from io import BytesIO
from webargs.core import MARSHMALLOW_VERSION_INFO
from webargs.testing import CommonTestCase
from tests.apps.aiohttp_app import create_app
Expand Down Expand Up @@ -63,3 +65,10 @@ def test_schema_as_kwargs_view(self, testapp):
assert testapp.get("/echo_use_schema_as_kwargs?name=Chandler").json == {
"name": "Chandler"
}

# https://github.com/sloria/webargs/pull/297
def test_empty_json_body(self, testapp):
environ = {"CONTENT_TYPE": "application/json", "wsgi.input": BytesIO(b"")}
req = webtest.TestRequest.blank("/echo", environ)
resp = testapp.do_request(req)
assert resp.json == {"name": "World"}

0 comments on commit 7454c35

Please sign in to comment.