diff --git a/lms/djangoapps/verify_student/image.py b/lms/djangoapps/verify_student/image.py index d672f8a69c..77773d2023 100644 --- a/lms/djangoapps/verify_student/image.py +++ b/lms/djangoapps/verify_student/image.py @@ -3,6 +3,7 @@ Image encoding helpers for the verification app. """ from __future__ import absolute_import +import base64 import logging log = logging.getLogger(__name__) @@ -30,7 +31,7 @@ def decode_image_data(data): """ try: - return (data.split(",")[1]).decode("base64") + return base64.b64decode(data.split(",")[1]) except (IndexError, UnicodeEncodeError): log.exception("Could not decode image data") raise InvalidImageData diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index e85240c474..ca70b38786 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -1553,7 +1553,7 @@ class TestSubmitPhotosForVerification(TestCase): # Since the user doesn't have an initial verification attempt, this should fail response = self._submit_photos(expected_status_code=400, face_image=self.IMAGE_DATA) self.assertEqual( - response.content, + response.content.decode('utf-8'), "Photo ID image is required if the user does not have an initial verification attempt." )