From 4250c3a0b3aa3ebfe67209f365feba57876534fd Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Fri, 23 Aug 2019 15:42:06 +0500 Subject: [PATCH] BOM-190 py3 assertion error --- lms/djangoapps/instructor_analytics/csvs.py | 4 ++-- lms/djangoapps/instructor_analytics/tests/test_csvs.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/instructor_analytics/csvs.py b/lms/djangoapps/instructor_analytics/csvs.py index a5ca1c5f6e..67700a8ddb 100644 --- a/lms/djangoapps/instructor_analytics/csvs.py +++ b/lms/djangoapps/instructor_analytics/csvs.py @@ -32,11 +32,11 @@ def create_csv_response(filename, header, datarows): quotechar='"', quoting=csv.QUOTE_ALL) - encoded_header = [six.text_type(s).encode('utf-8') for s in header] + encoded_header = [six.text_type(s) for s in header] csvwriter.writerow(encoded_header) for datarow in datarows: - encoded_row = [six.text_type(s).encode('utf-8') for s in datarow] + encoded_row = [six.text_type(s) for s in datarow] csvwriter.writerow(encoded_row) return response diff --git a/lms/djangoapps/instructor_analytics/tests/test_csvs.py b/lms/djangoapps/instructor_analytics/tests/test_csvs.py index e496f6964c..fc8f67d40a 100644 --- a/lms/djangoapps/instructor_analytics/tests/test_csvs.py +++ b/lms/djangoapps/instructor_analytics/tests/test_csvs.py @@ -81,7 +81,10 @@ class TestAnalyticsFormatDictlist(TestCase): res = create_csv_response('robot.csv', header, datarows) self.assertEqual(res['Content-Type'], 'text/csv') self.assertEqual(res['Content-Disposition'], u'attachment; filename={0}'.format('robot.csv')) - self.assertEqual(res.content.strip(), '"Name","Email"\r\n"Jim","jim@edy.org"\r\n"Jake","jake@edy.org"\r\n"Jeeves","jeeves@edy.org"') + self.assertEqual( + res.content.strip().decode('utf-8'), + '"Name","Email"\r\n"Jim","jim@edy.org"\r\n"Jake","jake@edy.org"\r\n"Jeeves","jeeves@edy.org"' + ) class TestAnalyticsFormatInstances(TestCase):