From 556c5ae088a9a34ac259af781a57eed92e396506 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 11 Nov 2018 17:01:17 +0200 Subject: [PATCH] tests/test_api.py: Use response.text instead of content Falcon's response content is raw bytes, while its text is a string. Let's use the latter so we can use json.loads() in Python 3.5, 3.6, and 3.7 with the same code. See: https://falcon.readthedocs.io/en/stable/api/testing.html --- tests/test_api.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 8f0c8fa..7c6f1b1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -23,12 +23,7 @@ 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) + response_doc = json.loads(response.text) assert isinstance(response_doc['downloads'], int) assert isinstance(response_doc['id'], int)