wrap call to json in try-except to make tests pass
This commit is contained in:
parent
199fa50a9d
commit
3f22b644b6
|
@ -1,4 +1,5 @@
|
||||||
import traceback
|
import traceback
|
||||||
|
from json import JSONDecodeError
|
||||||
|
|
||||||
from sanic.log import log
|
from sanic.log import log
|
||||||
|
|
||||||
|
@ -26,9 +27,14 @@ class SanicTestClient:
|
||||||
session, method.lower())(url, *args, **kwargs) as response:
|
session, method.lower())(url, *args, **kwargs) as response:
|
||||||
try:
|
try:
|
||||||
response.text = await response.text()
|
response.text = await response.text()
|
||||||
response.json = await response.json()
|
|
||||||
except UnicodeDecodeError as e:
|
except UnicodeDecodeError as e:
|
||||||
response.text = None
|
response.text = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
response.json = await response.json()
|
||||||
|
except (JSONDecodeError, UnicodeDecodeError):
|
||||||
|
response.json = None
|
||||||
|
|
||||||
response.body = await response.read()
|
response.body = await response.read()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user