From de0eafa0baf5142ff257e492a79026d228cf8db9 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 18 Sep 2019 14:57:10 -0400 Subject: [PATCH] BOM-618 Decode test client content. The django test client returns bytes, and many of our tests start using it like a string. This was fine in python 2 but not in python3. --- .../discussion/django_comment_client/tests/test_middleware.py | 4 ++-- lms/djangoapps/instructor/tests/test_tools.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py b/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py index 49f2d950fc..6e23ef2881 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/test_middleware.py @@ -30,7 +30,7 @@ class AjaxExceptionTestCase(TestCase): self.assertEqual(self.exception1.status_code, response1.status_code) self.assertEqual( {"errors": json.loads(text_type(self.exception1))}, - json.loads(response1.content) + json.loads(response1.content.decode('utf-8')) ) response2 = self.a.process_exception(self.request1, self.exception2) @@ -38,7 +38,7 @@ class AjaxExceptionTestCase(TestCase): self.assertEqual(self.exception2.status_code, response2.status_code) self.assertEqual( {"errors": [text_type(self.exception2)]}, - json.loads(response2.content) + json.loads(response2.content.decode('utf-8')) ) self.assertIsNone(self.a.process_exception(self.request1, self.exception0)) diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index 9ab7ac689d..1072f2acea 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -33,7 +33,7 @@ class TestDashboardError(unittest.TestCase): """ def test_response(self): error = tools.DashboardError(u'Oh noes!') - response = json.loads(error.response().content) + response = json.loads(error.response().content.decode('utf-8')) self.assertEqual(response, {'error': 'Oh noes!'}) @@ -50,7 +50,7 @@ class TestHandleDashboardError(unittest.TestCase): """ raise tools.DashboardError("Oh noes!") - response = json.loads(view(None, None).content) + response = json.loads(view(None, None).content.decode('utf-8')) self.assertEqual(response, {'error': 'Oh noes!'}) def test_no_error(self):