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 23c589c6ae..fe636626fd 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):