Merge pull request #21994 from edx/BOM-914

Fixed all instances of "TypeError: a bytes-like object is required, not 'str" - BOM-914
This commit is contained in:
Aarif
2019-10-16 01:44:31 +05:00
committed by GitHub
7 changed files with 11 additions and 17 deletions

View File

@@ -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)
]

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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'))

View File

@@ -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):
"""

View File

@@ -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)