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:
parent
586231eb2d
commit
d94134f80a
@ -23,7 +23,12 @@ def test_get_item(client):
|
|||||||
'''Test requesting a single item.'''
|
'''Test requesting a single item.'''
|
||||||
|
|
||||||
response = client.simulate_get('/item/17')
|
response = client.simulate_get('/item/17')
|
||||||
response_doc = json.loads(response.content)
|
|
||||||
|
# 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)
|
assert isinstance(response_doc['downloads'], int)
|
||||||
assert isinstance(response_doc['id'], int)
|
assert isinstance(response_doc['id'], int)
|
||||||
|
Loading…
Reference in New Issue
Block a user