From 9fac37588c4f15446397638c72efc79bfcf0d636 Mon Sep 17 00:00:00 2001 From: Nikola Kolevski Date: Tue, 20 Jun 2017 13:15:30 +0200 Subject: [PATCH 1/2] Allow textual responses when using test_client and aiohttp 2 --- sanic/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanic/testing.py b/sanic/testing.py index 09554e21..075185b7 100644 --- a/sanic/testing.py +++ b/sanic/testing.py @@ -32,7 +32,7 @@ class SanicTestClient: try: response.json = await response.json() - except (JSONDecodeError, UnicodeDecodeError): + except (JSONDecodeError, UnicodeDecodeError, aiohttp.ClientResponseError): response.json = None response.body = await response.read() From d865c5e2b64f57416123ec3f2e1d8d4515e927ea Mon Sep 17 00:00:00 2001 From: Nikola Kolevski Date: Tue, 20 Jun 2017 13:22:28 +0200 Subject: [PATCH 2/2] Conform to pep8 --- sanic/testing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sanic/testing.py b/sanic/testing.py index 075185b7..de26d025 100644 --- a/sanic/testing.py +++ b/sanic/testing.py @@ -32,7 +32,9 @@ class SanicTestClient: try: response.json = await response.json() - except (JSONDecodeError, UnicodeDecodeError, aiohttp.ClientResponseError): + except (JSONDecodeError, + UnicodeDecodeError, + aiohttp.ClientResponseError): response.json = None response.body = await response.read()