Fix verbose printing of json bodies

If a request is content-type application/json, but the body is
empty, a request to verbosely print the body of the test will
cause a JSONdecoder error.
This commit is contained in:
Chris Dent 2017-01-06 19:18:31 +00:00
parent c755719d1e
commit 3ea4c3b60d
2 changed files with 2 additions and 2 deletions

View File

@ -12,4 +12,4 @@
# under the License. # under the License.
"""See gabbi.driver and gabbbi.case.""" """See gabbi.driver and gabbbi.case."""
__version__ = '1.30.1' __version__ = '1.30.2'

View File

@ -148,7 +148,7 @@ class VerboseHttp(Http):
# handler's loads() and dumps(). Not doing that now # handler's loads() and dumps(). Not doing that now
# because it would be pointless (no other interesting # because it would be pointless (no other interesting
# handlers) and this approach may be entirely wrong. # handlers) and this approach may be entirely wrong.
if jsonhandler.JSONHandler.accepts(content_type): if content and jsonhandler.JSONHandler.accepts(content_type):
data = jsonhandler.JSONHandler.loads(content) data = jsonhandler.JSONHandler.loads(content)
content = jsonhandler.JSONHandler.dumps(data, pretty=True) content = jsonhandler.JSONHandler.dumps(data, pretty=True)
self._verbose_output('') self._verbose_output('')