1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 06:15:02 +01:00

tests/test_api.py: Try to add workaround for Python 3.5

In Python 3.5 it seems that json.loads() cannot decode a bytes, but
it works in Python 3.6 and 3.7. Let's try a workaround to see if we
can get it working on both Python 3.5 and 3.6+.

See: https://docs.python.org/3.5/library/json.html#json.loads
See: https://docs.python.org/3.6/library/json.html#json.loads
This commit is contained in:
Alan Orth 2018-11-11 16:54:09 +02:00
parent 586231eb2d
commit d94134f80a
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -23,6 +23,11 @@ def test_get_item(client):
'''Test requesting a single item.'''
response = client.simulate_get('/item/17')
# response.content is a bytes in Python 3.5
if isinstance(response.content, bytes):
response_doc = json.loads(response.content.decode('utf-8'))
else:
response_doc = json.loads(response.content)
assert isinstance(response_doc['downloads'], int)