From ee27c689e12e1074cbd7ae235f0b0c076130422a Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 23 Mar 2017 20:06:39 +0800 Subject: [PATCH 1/2] commented aiohttp load response body in testing --- sanic/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanic/testing.py b/sanic/testing.py index 4fde428c..611f709d 100644 --- a/sanic/testing.py +++ b/sanic/testing.py @@ -22,8 +22,8 @@ class SanicTestClient: cookies=cookies, connector=conn) as session: async with getattr( session, method.lower())(url, *args, **kwargs) as response: - response.text = await response.text() - response.body = await response.read() + # response.text = await response.text() + # response.body = await response.read() return response def _sanic_endpoint_test( From 1562b81522d827539545a28e592aed1966ce0099 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 23 Mar 2017 20:48:57 +0800 Subject: [PATCH 2/2] add arg load_body in testing --- sanic/testing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sanic/testing.py b/sanic/testing.py index 611f709d..d7e73e56 100644 --- a/sanic/testing.py +++ b/sanic/testing.py @@ -20,10 +20,12 @@ class SanicTestClient: conn = aiohttp.TCPConnector(verify_ssl=False) async with aiohttp.ClientSession( cookies=cookies, connector=conn) as session: + load_body = 'load_body' not in kwargs or kwargs.pop('load_body') async with getattr( session, method.lower())(url, *args, **kwargs) as response: - # response.text = await response.text() - # response.body = await response.read() + if load_body: + response.text = await response.text() + response.body = await response.read() return response def _sanic_endpoint_test(