From 602970ed90fb0a4e1b080ecf0464fe1676329b0e Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 13 Aug 2019 13:54:49 -0400 Subject: [PATCH] Fix test collection for CMS in python 3. (#21338) --- .../views/tests/test_container_page.py | 14 +++++++------- .../contentstore/views/tests/test_item.py | 5 +++-- .../contentstore/views/tests/test_transcripts.py | 2 +- .../xmodule/video_module/transcripts_utils.py | 12 ++++++------ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py index 60a726cc43..fddf3bf6e8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py @@ -63,9 +63,9 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): u'data-locator="{0}" data-course-key="{0.course_key}">'.format(self.child_container.location) ), expected_breadcrumbs=( - ur'\s*Week 1\s*\s*' - ur'\s*Lesson 1\s*\s*' - ur'\s*Unit\s*' + u'\\s*Week 1\\s*\\s*' + u'\\s*Lesson 1\\s*\\s*' + u'\\s*Unit\\s*' ).format( course=re.escape(six.text_type(self.course.id)), unit=re.escape(six.text_type(self.vertical.location)), @@ -91,10 +91,10 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): u'data-locator="{0}" data-course-key="{0.course_key}">'.format(draft_container.location) ), expected_breadcrumbs=( - ur'\s*Week 1\s*\s*' - ur'\s*Lesson 1\s*\s*' - ur'\s*Unit\s*\s*' - ur'\s*Split Test\s*' + u'\\s*Week 1\\s*\\s*' + u'\\s*Lesson 1\\s*\\s*' + u'\\s*Unit\\s*\\s*' + u'\\s*Split Test\\s*' ).format( course=re.escape(six.text_type(self.course.id)), unit=re.escape(six.text_type(self.vertical.location)), diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index dfbf11ece7..97a03775e2 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -2,6 +2,7 @@ from __future__ import absolute_import import json +import re from datetime import datetime, timedelta import ddt @@ -255,8 +256,8 @@ class GetItemTest(ItemTest): html, # The instance of the wrapper class will have an auto-generated ID. Allow any # characters after wrapper. - ur'"/container/{}" class="action-button">\s*View'.format( - wrapper_usage_key + u'"/container/{}" class="action-button">\\s*View'.format( + re.escape(six.text_type(wrapper_usage_key)) ) ) diff --git a/cms/djangoapps/contentstore/views/tests/test_transcripts.py b/cms/djangoapps/contentstore/views/tests/test_transcripts.py index f6d87ef34e..dffc91ed07 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -35,7 +35,7 @@ from xmodule.video_module.transcripts_utils import ( TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex -SRT_TRANSCRIPT_CONTENT = """0 +SRT_TRANSCRIPT_CONTENT = b"""0 00:00:10,500 --> 00:00:13,000 Elephant's Dream diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index 32c52c2330..10e8aa2cbc 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -624,13 +624,13 @@ class Transcript(object): """ Container for transcript methods. """ - SRT = 'srt' - TXT = 'txt' - SJSON = 'sjson' + SRT = u'srt' + TXT = u'txt' + SJSON = u'sjson' mime_types = { - SRT: 'application/x-subrip; charset=utf-8', - TXT: 'text/plain; charset=utf-8', - SJSON: 'application/json', + SRT: u'application/x-subrip; charset=utf-8', + TXT: u'text/plain; charset=utf-8', + SJSON: u'application/json', } @staticmethod