diff --git a/cms/djangoapps/contentstore/tests/test_export_git.py b/cms/djangoapps/contentstore/tests/test_export_git.py index 27ae16da16..9b9c58b54b 100644 --- a/cms/djangoapps/contentstore/tests/test_export_git.py +++ b/cms/djangoapps/contentstore/tests/test_export_git.py @@ -69,7 +69,7 @@ class TestExportGit(CourseTestCase): self.assertIn( ('giturl must be defined in your ' 'course settings before you can export to git.'), - response.content + response.content.decode('utf-8') ) response = self.client.get('{}?action=push'.format(self.test_url)) @@ -77,7 +77,7 @@ class TestExportGit(CourseTestCase): self.assertIn( ('giturl must be defined in your ' 'course settings before you can export to git.'), - response.content + response.content.decode('utf-8') ) def test_course_export_failures(self): @@ -88,7 +88,7 @@ class TestExportGit(CourseTestCase): modulestore().update_item(self.course_module, self.user.id) response = self.client.get('{}?action=push'.format(self.test_url)) - self.assertIn('Export Failed:', response.content) + self.assertIn('Export Failed:', response.content.decode('utf-8')) def test_exception_translation(self): """ @@ -98,7 +98,7 @@ class TestExportGit(CourseTestCase): modulestore().update_item(self.course_module, self.user.id) response = self.client.get('{}?action=push'.format(self.test_url)) - self.assertNotIn('django.utils.functional.__proxy__', response.content) + self.assertNotIn('django.utils.functional.__proxy__', response.content.decode('utf-8')) def test_course_export_success(self): """ @@ -107,7 +107,7 @@ class TestExportGit(CourseTestCase): self.make_bare_repo_with_course('test_repo') response = self.client.get('{}?action=push'.format(self.test_url)) - self.assertIn('Export Succeeded', response.content) + self.assertIn('Export Succeeded', response.content.decode('utf-8')) def test_repo_with_dots(self): """ @@ -115,7 +115,7 @@ class TestExportGit(CourseTestCase): """ self.make_bare_repo_with_course('test.repo') response = self.client.get('{}?action=push'.format(self.test_url)) - self.assertIn('Export Succeeded', response.content) + self.assertIn('Export Succeeded', response.content.decode('utf-8')) def test_dirty_repo(self): """ diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index bba9984e76..dc0bfe373d 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -873,7 +873,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): Verify that `get_transcript` function returns correct data when transcript is in content store. """ base_filename = 'video_101.srt' - self.upload_file(self.create_srt_file(self.subs_srt), self.video.location, base_filename) + self.upload_file(self.create_srt_file(self.subs_srt.encode('utf-8')), self.video.location, base_filename) self.create_transcript(subs_id, language, base_filename, youtube_id_1_0, html5_sources) content, file_name, mimetype = transcripts_utils.get_transcript( self.video, @@ -935,7 +935,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): """ Verify that `get_transcript` function returns correct exception when transcript content is empty. """ - self.upload_file(self.create_srt_file(''), self.video.location, 'ur_video_101.srt') + self.upload_file(self.create_srt_file(b''), self.video.location, 'ur_video_101.srt') self.create_transcript('', 'ur', 'ur_video_101.srt') with self.assertRaises(NotFoundError) as no_content_exception: diff --git a/cms/djangoapps/maintenance/tests.py b/cms/djangoapps/maintenance/tests.py index 2b529792fc..9887caa733 100644 --- a/cms/djangoapps/maintenance/tests.py +++ b/cms/djangoapps/maintenance/tests.py @@ -289,7 +289,7 @@ class TestAnnouncementsViews(MaintenanceViewTestCase): """ url = reverse("maintenance:announcement_index") response = self.client.get(url) - self.assertIn('
', response.content) + self.assertIn('
', response.content.decode('utf-8')) def test_create(self): """ @@ -308,7 +308,7 @@ class TestAnnouncementsViews(MaintenanceViewTestCase): announcement.save() url = reverse("maintenance:announcement_edit", kwargs={"pk": announcement.pk}) response = self.client.get(url) - self.assertIn('
', response.content) + self.assertIn('
', response.content.decode('utf-8')) self.client.post(url, {"content": "Test Edit Announcement", "active": True}) announcement = Announcement.objects.get(pk=announcement.pk) self.assertEquals(announcement.content, "Test Edit Announcement") diff --git a/common/lib/xmodule/xmodule/contentstore/mongo.py b/common/lib/xmodule/xmodule/contentstore/mongo.py index 7ab6c42d2d..649e07bc7a 100644 --- a/common/lib/xmodule/xmodule/contentstore/mongo.py +++ b/common/lib/xmodule/xmodule/contentstore/mongo.py @@ -99,6 +99,7 @@ class MongoContentStore(ContentStore): import_path=content.import_path, # getattr b/c caching may mean some pickled instances don't have attr locked=getattr(content, 'locked', False)) as fp: + # It seems that this code thought that only some specific object would have the `__iter__` attribute # but the bytes object in python 3 has one and should not use the chunking logic. if hasattr(content.data, '__iter__') and not isinstance(content.data, six.binary_type): diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index 5a513bca58..5556a7448b 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -126,7 +126,7 @@ def save_subs_to_store(subs, subs_id, item, language='en'): Returns: location of saved subtitles. """ - filedata = json.dumps(subs, indent=2) + filedata = json.dumps(subs, indent=2).encode('utf-8') filename = subs_filename(subs_id, language) return save_to_store(filedata, filename, 'application/json', item.location)