diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py
index e1d6962402..32684badba 100644
--- a/lms/djangoapps/commerce/tests/test_views.py
+++ b/lms/djangoapps/commerce/tests/test_views.py
@@ -95,7 +95,7 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
else:
expected_pattern = r"
(\s+)Payment Failed"
response = self.post_to_receipt_page(post_data)
- self.assertRegexpMatches(response.content, expected_pattern)
+ self.assertRegexpMatches(response.content.decode('utf-8'), expected_pattern)
@ddt.data('ACCEPT', 'REJECT', 'ERROR')
def test_cybersource_decision(self, decision):
@@ -106,7 +106,7 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
post_data = {'decision': decision, 'reason_code': '200', 'signed_field_names': 'dummy'}
expected_pattern = r"(\s+)Receipt" if decision == 'ACCEPT' else r"(\s+)Payment Failed"
response = self.post_to_receipt_page(post_data)
- self.assertRegexpMatches(response.content, expected_pattern)
+ self.assertRegexpMatches(response.content.decode('utf-8'), expected_pattern)
@ddt.data(True, False)
@mock.patch('lms.djangoapps.commerce.views.is_user_payment_error')
@@ -123,8 +123,8 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
user_message = "There was a problem with this transaction"
system_message = "A system error occurred while processing your payment"
- self.assertRegexpMatches(response.content, user_message if is_user_message_expected else system_message)
- self.assertNotRegexpMatches(response.content, user_message if not is_user_message_expected else system_message)
+ self.assertRegexpMatches(response.content.decode('utf-8'), user_message if is_user_message_expected else system_message)
+ self.assertNotRegexpMatches(response.content.decode('utf-8'), user_message if not is_user_message_expected else system_message)
@with_comprehensive_theme("edx.org")
def test_hide_nav_header(self):
diff --git a/lms/djangoapps/courseware/tests/test_i18n.py b/lms/djangoapps/courseware/tests/test_i18n.py
index 2c658685b0..8133af78c5 100644
--- a/lms/djangoapps/courseware/tests/test_i18n.py
+++ b/lms/djangoapps/courseware/tests/test_i18n.py
@@ -80,30 +80,30 @@ class I18nTestCase(BaseI18nTestCase):
def test_default_is_en(self):
self.release_languages('fr')
response = self.client.get('/')
- self.assert_tag_has_attr(response.content, "html", "lang", "en")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "en")
self.assertEqual(response['Content-Language'], 'en')
- self.assert_tag_has_attr(response.content, "body", "class", "lang_en")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_en")
def test_esperanto(self):
self.release_languages('fr, eo')
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='eo')
- self.assert_tag_has_attr(response.content, "html", "lang", "eo")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
self.assertEqual(response['Content-Language'], 'eo')
- self.assert_tag_has_attr(response.content, "body", "class", "lang_eo")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_eo")
def test_switching_languages_bidi(self):
self.release_languages('ar, eo')
response = self.client.get('/')
- self.assert_tag_has_attr(response.content, "html", "lang", "en")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "en")
self.assertEqual(response['Content-Language'], 'en')
- self.assert_tag_has_attr(response.content, "body", "class", "lang_en")
- self.assert_tag_has_attr(response.content, "body", "class", "ltr")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_en")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "ltr")
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='ar')
- self.assert_tag_has_attr(response.content, "html", "lang", "ar")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "ar")
self.assertEqual(response['Content-Language'], 'ar')
- self.assert_tag_has_attr(response.content, "body", "class", "lang_ar")
- self.assert_tag_has_attr(response.content, "body", "class", "rtl")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "lang_ar")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "body", "class", "rtl")
class I18nRegressionTests(BaseI18nTestCase):
@@ -114,7 +114,7 @@ class I18nRegressionTests(BaseI18nTestCase):
# Regression test; LOC-72, and an issue with Django
self.release_languages('es-419')
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='es-419')
- self.assert_tag_has_attr(response.content, "html", "lang", "es-419")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "es-419")
def test_unreleased_lang_resolution(self):
# Regression test; LOC-85
@@ -126,12 +126,12 @@ class I18nRegressionTests(BaseI18nTestCase):
# in the http request (NOT with the ?preview-lang query param) should
# receive files for 'fa'
response = self.client.get(self.url, HTTP_ACCEPT_LANGUAGE='fa-ir')
- self.assert_tag_has_attr(response.content, "html", "lang", "fa")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "fa")
# Now try to access with dark lang
self.client.post(self.preview_language_url, {'preview_language': 'fa-ir', 'action': 'set_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", "fa-ir")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "fa-ir")
def test_preview_lang(self):
self.user_login()
@@ -141,23 +141,23 @@ class I18nRegressionTests(BaseI18nTestCase):
site_lang = settings.LANGUAGE_CODE
# Visit the front page; verify we see site default lang
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", site_lang)
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", site_lang)
# Verify we can switch language using the preview-lang query param
# Set the language
self.client.post(self.preview_language_url, {'preview_language': 'eo', 'action': 'set_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", "eo")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
# We should be able to see released languages using preview-lang, too
self.client.post(self.preview_language_url, {'preview_language': 'es-419', 'action': 'set_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", "es-419")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "es-419")
# Clearing the language should go back to site default
self.client.post(self.preview_language_url, {'action': 'reset_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", site_lang)
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", site_lang)
class I18nLangPrefTests(BaseI18nTestCase):
@@ -187,18 +187,18 @@ class I18nLangPrefTests(BaseI18nTestCase):
# Visit the front page; verify we see site default lang
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", self.site_lang)
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", self.site_lang)
# Set user language preference
self.set_lang_preference('ar')
# and verify we now get an ar response
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", 'ar')
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'ar')
# Verify that switching language preference gives the right language
self.set_lang_preference('es-419')
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", 'es-419')
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'es-419')
def test_preview_precedence(self):
# Regression test; LOC-87
@@ -210,13 +210,13 @@ class I18nLangPrefTests(BaseI18nTestCase):
self.client.post(self.preview_language_url, {'preview_language': 'eo', 'action': 'set_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", 'eo')
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'eo')
# Hitting another page should keep the dark language set.
response = self.client.get(reverse('courses'))
- self.assert_tag_has_attr(response.content, "html", "lang", "eo")
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", "eo")
# Clearing language must set language back to preference language
self.client.post(self.preview_language_url, {'action': 'reset_preview_language'})
response = self.client.get(self.url)
- self.assert_tag_has_attr(response.content, "html", "lang", 'ar')
+ self.assert_tag_has_attr(response.content.decode('utf-8'), "html", "lang", 'ar')
diff --git a/lms/djangoapps/learner_dashboard/tests/test_programs.py b/lms/djangoapps/learner_dashboard/tests/test_programs.py
index 5a300de3e9..1a63165790 100644
--- a/lms/djangoapps/learner_dashboard/tests/test_programs.py
+++ b/lms/djangoapps/learner_dashboard/tests/test_programs.py
@@ -40,7 +40,7 @@ def load_serialized_data(response, key):
Extract and deserialize serialized data from the response.
"""
pattern = re.compile(u'{key}: (?P\\[.*\\])'.format(key=key))
- match = pattern.search(response.content)
+ match = pattern.search(response.content.decode('utf-8'))
serialized = match.group('data')
return json.loads(serialized)
diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py
index 8094e69838..f0194d25c7 100644
--- a/lms/djangoapps/support/tests/test_views.py
+++ b/lms/djangoapps/support/tests/test_views.py
@@ -331,7 +331,7 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase
data['course_id'] = six.text_type(self.course.id)
response = self.client.post(self.url, data)
self.assertEqual(response.status_code, 400)
- self.assertIsNotNone(re.match(error_message, response.content))
+ self.assertIsNotNone(re.match(error_message, response.content.decode('utf-8')))
self.assert_enrollment(CourseMode.AUDIT)
self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))