From eef343d212d923749030aaff51929e8b1813701d Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Wed, 28 Aug 2019 15:49:58 +0500 Subject: [PATCH] BOM-264 py3 unit test fix --- lms/djangoapps/verify_student/image.py | 3 ++- lms/djangoapps/verify_student/tests/test_views.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 67e8a85f17..be4d538949 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." )