diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 3d6d5accff61892b5c53785f813e5b4042d474cc..5c91d5ad2924c20d3363f20977ce1d44667b0690 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -564,7 +564,7 @@ class ImportTestCase(BaseCourseTestCase): # Expect to find an error/exception about characters in "®esources" expect = "InvalidKeyError" errors = [ - (msg.encode("utf-8"), err.encode("utf-8")) + (msg, err) for msg, err in modulestore.get_course_errors(course.id) ] diff --git a/lms/djangoapps/courseware/tests/test_entrance_exam.py b/lms/djangoapps/courseware/tests/test_entrance_exam.py index 346074eb0c33a0b714062eee06519b73ca2af4b8..736ce547b12502ab77dde0043485d9ce5a51c38e 100644 --- a/lms/djangoapps/courseware/tests/test_entrance_exam.py +++ b/lms/djangoapps/courseware/tests/test_entrance_exam.py @@ -257,7 +257,7 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest resp = self.client.get(url) self.assertRedirects(resp, expected_url, status_code=302, target_status_code=200) resp = self.client.get(expected_url) - self.assertNotIn('Exam Vertical - Unit 1', resp.content) + self.assertNotContains(resp, 'Exam Vertical - Unit 1') def test_entrance_exam_content_presence(self): """ @@ -353,8 +353,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest ) resp = self.client.get(url) self.assertEqual(resp.status_code, 200) - self.assertNotIn('To access course materials, you must score', resp.content) - self.assertNotIn('You have passed the entrance exam.', resp.content) + self.assertNotContains(resp, 'To access course materials, you must score') + self.assertNotContains(resp, 'You have passed the entrance exam.') # TODO: LEARNER-71: Do we need to adjust or remove this test? @override_waffle_flag(COURSE_OUTLINE_PAGE_FLAG, active=False) diff --git a/lms/djangoapps/courseware/tests/test_password_reset.py b/lms/djangoapps/courseware/tests/test_password_reset.py index ecab0d57b43847580473e709894c7c03e0c518f6..863cbe07284a061519a79d8a2aad6b83e2aee664 100644 --- a/lms/djangoapps/courseware/tests/test_password_reset.py +++ b/lms/djangoapps/courseware/tests/test_password_reset.py @@ -75,10 +75,7 @@ class TestPasswordReset(LoginEnrollmentTestCase): 'new_password2': 'foo', }, follow=True) - self.assertNotIn( - success_msg, - resp.content - ) + self.assertNotContains(resp, success_msg) # try to reset password with a long enough password user = User.objects.get(email=staff_email) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index b9f18d34a79f70f908e33e190afb3394010a68cd..3fcc0036670f43f4fcb1ea2a70e008264c785c4b 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -725,7 +725,6 @@ class ViewsTestCase(ModuleStoreTestCase): 'location': six.text_type(usage_key), }) response = client.get(url) - response_content = HTMLParser().unescape(response.content) expected_time = datetime.now() + timedelta(hours=hour_diff) expected_tz = expected_time.strftime('%Z') self.assertContains(response, expected_tz) diff --git a/lms/djangoapps/instructor/tests/test_proctoring.py b/lms/djangoapps/instructor/tests/test_proctoring.py index 6cbd129c76c8b8bc52012ffba2f16fd53e12aabf..ac399897d74f56e1e3e51273b82b5fed9aca3373 100644 --- a/lms/djangoapps/instructor/tests/test_proctoring.py +++ b/lms/djangoapps/instructor/tests/test_proctoring.py @@ -156,5 +156,5 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase): """ func = self.assertIn if available else self.assertNotIn response = self.client.get(self.url) - func(self.proctoring_link, response.content) - func('proctoring-wrapper', response.content) + func(self.proctoring_link, response.content.decode('utf-8')) + func('proctoring-wrapper', response.content.decode('utf-8')) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index 9928bd6c061f100c8b231a60d1a2af75600d0548..6a14f602904c5989e0e82d73e78f200161da1ddf 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -429,11 +429,9 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT response = self.client.get(self.url) - self.assertEquals( - expected_result, - 'CCX Coaches are able to create their own Custom Courses based on this course' - in response.content.decode('utf-8') - ) + self.assertEquals(expected_result, + 'CCX Coaches are able to create their own Custom Courses based on this course' + in response.content.decode('utf-8')) def test_grade_cutoffs(self): """ diff --git a/openedx/core/lib/api/test_utils.py b/openedx/core/lib/api/test_utils.py index 93f25c9abbecfc90280d013d5ef4b77de801a8bd..6a684f834b190c7176ef7e914b16e5d27f076bdf 100644 --- a/openedx/core/lib/api/test_utils.py +++ b/openedx/core/lib/api/test_utils.py @@ -86,6 +86,6 @@ class ApiTestCase(TestCase): # Django rest framework interprets basic auth headers # as an attempt to authenticate with the API. # We don't want this for views available to anonymous users. - basic_auth_header = b"Basic " + base64.b64encode('username:password'.encode('utf-8')) + basic_auth_header = "Basic " + base64.b64encode('username:password'.encode('utf-8')).decode('utf-8') response = getattr(self.client, method)(uri, HTTP_AUTHORIZATION=basic_auth_header) self.assertNotEqual(response.status_code, 403)