Autoserialization should work not only for dicts, but for lists too
SergSlipushenko opened this issue · 0 comments
SergSlipushenko commented
I hit this issue on httmock==1.2.3.
Traceback (most recent call last):
File "/home/sslypushenko/projects/refstack/refstack/tests/unit/test_api.py", line 255, in test_get_capabilities
result = self.controller.get()
File "/home/sslypushenko/projects/refstack/refstack/api/controllers/v1.py", line 206, in get
json = response.json()
File "/home/sslypushenko/projects/refstack/.tox/py34/lib/python3.4/site-packages/requests/models.py", line 809, in json
encoding = guess_json_utf(self.content)
File "/home/sslypushenko/projects/refstack/.tox/py34/lib/python3.4/site-packages/requests/utils.py", line 631, in guess_json_utf
nullcount = sample.count(_null)
TypeError: Can't convert 'bytes' object to str implicitly
I know that you fixed this issue for dicts, but content response can be a list too.
It is a kind of example for from our code:
@httmock.all_requests
def api_mock(url, request):
headers = {'content-type': 'application/json'}
content = [1,2,3]
content = json.dumps(content)
return httmock.response(200, content, headers, None, 5, request)