add arg load_body in testing

This commit is contained in:
ivan 2017-03-23 20:48:57 +08:00
parent be1016ace6
commit 1562b81522

View File

@ -20,10 +20,12 @@ class SanicTestClient:
conn = aiohttp.TCPConnector(verify_ssl=False) conn = aiohttp.TCPConnector(verify_ssl=False)
async with aiohttp.ClientSession( async with aiohttp.ClientSession(
cookies=cookies, connector=conn) as session: cookies=cookies, connector=conn) as session:
load_body = 'load_body' not in kwargs or kwargs.pop('load_body')
async with getattr( async with getattr(
session, method.lower())(url, *args, **kwargs) as response: session, method.lower())(url, *args, **kwargs) as response:
# response.text = await response.text() if load_body:
# response.body = await response.read() response.text = await response.text()
response.body = await response.read()
return response return response
def _sanic_endpoint_test( def _sanic_endpoint_test(