fix unicode strings in common/

This commit is contained in:
Matthew Piatetsky
2019-02-01 13:34:57 -05:00
parent 33d16d8e24
commit 9681ca36b8
88 changed files with 457 additions and 456 deletions

View File

@@ -578,7 +578,7 @@ class CohortConfigurationTest(EventsTestMixin, UniqueCourseTest, CohortTestMixin
start_time = datetime.now(UTC)
self.cohort_management_page.upload_cohort_file(filename)
self._verify_cohort_by_csv_notification(
"Your file '{}' has been uploaded. Allow a few minutes for processing.".format(filename)
u"Your file '{}' has been uploaded. Allow a few minutes for processing.".format(filename)
)
if not skip_events:

View File

@@ -50,7 +50,7 @@ class CohortedDiscussionTestMixin(BaseDiscussionMixin, CohortTestMixin):
self.refresh_thread_page(self.thread_id)
self.assertEquals(
self.thread_page.get_group_visibility_label(),
"This post is visible only to {}.".format(self.cohort_1_name)
u"This post is visible only to {}.".format(self.cohort_1_name)
)
# Disable cohorts and verify that the post now shows as visible to everyone.

View File

@@ -36,7 +36,7 @@ from common.test.acceptance.tests.helpers import UniqueCourseTest, get_modal_ale
from openedx.core.lib.tests import attr
THREAD_CONTENT_WITH_LATEX = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
THREAD_CONTENT_WITH_LATEX = u"""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit sse cillum dolore eu fugiat nulla pariatur.
@@ -123,7 +123,7 @@ class DiscussionResponsePaginationTestMixin(BaseDiscussionMixin):
(
None if response_total == 0 else
"Showing all responses" if response_total == displayed_responses else
"Showing first {} responses".format(displayed_responses)
u"Showing first {} responses".format(displayed_responses)
)
)
self.assertEqual(
@@ -648,10 +648,10 @@ class DiscussionResponseEditTest(BaseDiscussionTestCase):
page.submit_response_edit(response_id, description)
expected_response_html = (
'<p><a href="{}">{}</a></p>'.format(url, description)
u'<p><a href="{}">{}</a></p>'.format(url, description)
)
actual_response_html = page.q(
css=".response_{} .response-body".format(response_id)
css=u".response_{} .response-body".format(response_id)
).html[0]
self.assertEqual(expected_response_html, actual_response_html)
@@ -682,10 +682,10 @@ class DiscussionResponseEditTest(BaseDiscussionTestCase):
page.submit_response_edit(response_id, '')
expected_response_html = (
'<p><img src="{}" alt="{}" title=""></p>'.format(url, description)
u'<p><img src="{}" alt="{}" title=""></p>'.format(url, description)
)
actual_response_html = page.q(
css=".response_{} .response-body".format(response_id)
css=u".response_{} .response-body".format(response_id)
).html[0]
self.assertEqual(expected_response_html, actual_response_html)
@@ -737,11 +737,11 @@ class DiscussionResponseEditTest(BaseDiscussionTestCase):
page.submit_response_edit(response_id, "Some content")
expected_response_html = (
'<p>Some content<img src="{}" alt="{}" title=""></p>'.format(
u'<p>Some content<img src="{}" alt="{}" title=""></p>'.format(
url, description)
)
actual_response_html = page.q(
css=".response_{} .response-body".format(response_id)
css=u".response_{} .response-body".format(response_id)
).html[0]
self.assertEqual(expected_response_html, actual_response_html)
@@ -1027,9 +1027,9 @@ class DiscussionEditorPreviewTest(UniqueCourseTest):
appear in the preview box
"""
self.page.set_new_post_editor_value(
r'\begin{equation}'
r'\tau_g(\omega) = - \frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) '
r'\end{equation}'
ur'\begin{equation}'
ur'\tau_g(\omega) = - \frac{d}{d\omega}\phi(\omega) \hspace{2em} (1) '
ur'\end{equation}'
)
self.assertIsNotNone(self.page.get_new_post_preview_text())
self.page.click_element(".cancel")

View File

@@ -482,7 +482,7 @@ class DivisionSchemeTest(BaseDividedDiscussionTest, BaseDiscussionMixin):
refresh_thread_page()
self.assertEquals(
self.thread_page.get_group_visibility_label(),
"This post is visible only to {}.".format("Audit")
u"This post is visible only to {}.".format("Audit")
)
# Disable dividing discussions and verify that the post now shows as visible to everyone.

View File

@@ -58,7 +58,7 @@ def skip_if_browser(browser):
@functools.wraps(test_function)
def wrapper(self, *args, **kwargs):
if self.browser.name == browser:
raise SkipTest('Skipping as this test will not work with {}'.format(browser))
raise SkipTest(u'Skipping as this test will not work with {}'.format(browser))
test_function(self, *args, **kwargs)
return wrapper
return decorator
@@ -102,7 +102,7 @@ def is_focused_on_element(browser, selector):
"""
Check if the focus is on the element that matches the selector.
"""
return browser.execute_script("return $('{}').is(':focus')".format(selector))
return browser.execute_script(u"return $('{}').is(':focus')".format(selector))
def load_data_str(rel_path):
@@ -159,7 +159,7 @@ def disable_css_animations(page):
"""
Disable CSS3 animations, transitions, transforms.
"""
page.browser.execute_script("""
page.browser.execute_script(u"""
var id = 'no-transitions';
// if styles were already added, just do nothing.
@@ -236,7 +236,7 @@ def select_option_by_text(select_browser_query, option_text, focus_out=False):
except StaleElementReferenceException:
return False
msg = 'Selected option {}'.format(option_text)
msg = u'Selected option {}'.format(option_text)
EmptyPromise(lambda: select_option(select_browser_query, option_text), msg).fulfill()
@@ -350,7 +350,7 @@ def get_element_padding(page, selector):
progress_page.get_element_padding('.wrapper-msg.wrapper-auto-cert')
"""
js_script = """
js_script = u"""
var $element = $('%(selector)s');
element_padding = {
@@ -380,7 +380,7 @@ def create_multiple_choice_xml(correct_choice=2, num_choices=4):
choices[correct_choice] = True
choice_names = ['choice_{}'.format(index) for index in range(num_choices)]
question_text = 'The correct answer is Choice {}'.format(correct_choice)
question_text = u'The correct answer is Choice {}'.format(correct_choice)
return MultipleChoiceResponseXMLFactory().build_xml(
question_text=question_text,
@@ -434,7 +434,7 @@ def assert_opened_help_link_is_correct(test, url):
# Check that the URL loads. Can't do this in the browser because it might
# be loading a "Maze Found" missing content page.
response = requests.get(url)
test.assertEqual(response.status_code, 200, "URL {!r} returned {}".format(url, response.status_code))
test.assertEqual(response.status_code, 200, u"URL {!r} returned {}".format(url, response.status_code))
EDX_BOOKS = {
@@ -560,7 +560,7 @@ class EventsTestMixin(TestCase):
# This is a bit of a hack, Promise calls str(description), so I set the description to an object with a
# custom __str__ and have it do some intelligent stuff to generate a helpful error message.
CollectedEventsDescription(
'Waiting for {number_of_matches} events to match the filter:\n{event_filter}'.format(
u'Waiting for {number_of_matches} events to match the filter:\n{event_filter}'.format(
number_of_matches=number_of_matches,
event_filter=self.event_filter_to_descriptive_string(event_filter),
),
@@ -855,7 +855,7 @@ class YouTubeStubConfig(object):
if not response.ok:
raise YouTubeConfigError(
'YouTube Server Configuration Failed. URL {0}, Configuration Data: {1}, Status was {2}'.format(
u'YouTube Server Configuration Failed. URL {0}, Configuration Data: {1}, Status was {2}'.format(
youtube_stub_config_url, config, response.status_code))
@classmethod
@@ -873,7 +873,7 @@ class YouTubeStubConfig(object):
if not response.ok:
raise YouTubeConfigError(
'YouTube Server Configuration Failed. URL: {0} Status was {1}'.format(
u'YouTube Server Configuration Failed. URL: {0} Status was {1}'.format(
youtube_stub_config_url, response.status_code))
@classmethod

View File

@@ -52,7 +52,7 @@ class LibraryContentTestBase(UniqueCourseTest):
self.course_info['run']
)
self.library_fixture = LibraryFixture('test_org', self.unique_id, 'Test Library {}'.format(self.unique_id))
self.library_fixture = LibraryFixture('test_org', self.unique_id, u'Test Library {}'.format(self.unique_id))
self.populate_library_fixture(self.library_fixture)
self.library_fixture.install()
@@ -218,11 +218,11 @@ class StudioLibraryContainerCapaFilterTest(LibraryContentTestBase, TestWithSearc
def _get_problem_choice_group_text(self, name, items):
""" Generates Choice Group CAPA problem XML """
items_text = "\n".join([
"<choice correct='{correct}'>{item}</choice>".format(correct=correct, item=item)
u"<choice correct='{correct}'>{item}</choice>".format(correct=correct, item=item)
for item, correct in items
])
return textwrap.dedent("""
return textwrap.dedent(u"""
<problem>
<p>{name}</p>
<multiplechoiceresponse>
@@ -234,7 +234,7 @@ class StudioLibraryContainerCapaFilterTest(LibraryContentTestBase, TestWithSearc
""" Generates Select Option CAPA problem XML """
items_text = ",".join(["'{0}'".format(item) for item in items])
return textwrap.dedent("""
return textwrap.dedent(u"""
<problem>
<p>{name}</p>
<optionresponse>

View File

@@ -263,8 +263,8 @@ class LoginFromCombinedPageTest(UniqueCourseTest):
"""
Create a new user with a unique name and email.
"""
username = "test_{uuid}".format(uuid=self.unique_id[0:6])
email = "{user}@example.com".format(user=username)
username = u"test_{uuid}".format(uuid=self.unique_id[0:6])
email = u"{user}@example.com".format(user=username)
password = "password"
# Create the user (automatically logs us in)
@@ -306,8 +306,8 @@ class RegisterFromCombinedPageTest(UniqueCourseTest):
self.register_page.visit()
# Fill in the form and submit it
username = "test_{uuid}".format(uuid=self.unique_id[0:6])
email = "{user}@example.com".format(user=username)
username = u"test_{uuid}".format(uuid=self.unique_id[0:6])
email = u"{user}@example.com".format(user=username)
self.register_page.register(
email=email,
password="password",
@@ -329,8 +329,8 @@ class RegisterFromCombinedPageTest(UniqueCourseTest):
# Don't agree to the terms of service / honor code.
# Don't specify a country code, which is required.
# Don't specify a favorite movie.
username = "test_{uuid}".format(uuid=self.unique_id[0:6])
email = "{user}@example.com".format(user=username)
username = u"test_{uuid}".format(uuid=self.unique_id[0:6])
email = u"{user}@example.com".format(user=username)
self.register_page.register(
email=email,
password="password",
@@ -721,7 +721,7 @@ class PDFTextBooksTabTest(UniqueCourseTest):
# Add PDF textbooks to course fixture.
for i in range(1, 3):
course_fix.add_textbook("PDF Book {}".format(i), [{"title": "Chapter Of Book {}".format(i), "url": ""}])
course_fix.add_textbook(u"PDF Book {}".format(i), [{"title": u"Chapter Of Book {}".format(i), "url": ""}])
course_fix.install()
@@ -736,7 +736,7 @@ class PDFTextBooksTabTest(UniqueCourseTest):
# Verify each PDF textbook tab by visiting, it will fail if correct tab is not loaded.
for i in range(1, 3):
self.tab_nav.go_to_tab("PDF Book {}".format(i))
self.tab_nav.go_to_tab(u"PDF Book {}".format(i))
@attr(shard=1)

View File

@@ -113,9 +113,9 @@ class CoursewareTest(UniqueCourseTest):
"""
xblocks = self.course_fix.get_nested_xblocks(category="problem")
for index in range(1, len(xblocks) + 1):
test_section_title = 'Test Section {}'.format(index)
test_subsection_title = 'Test Subsection {}'.format(index)
test_unit_title = 'Test Problem {}'.format(index)
test_section_title = u'Test Section {}'.format(index)
test_subsection_title = u'Test Subsection {}'.format(index)
test_unit_title = u'Test Problem {}'.format(index)
self.course_home_page.visit()
self.course_home_page.outline.go_to_section(test_section_title, test_subsection_title)
course_nav = self.courseware_page.nav

View File

@@ -9,8 +9,8 @@ from common.test.acceptance.pages.common.auto_auth import AutoAuthPage
from common.test.acceptance.pages.lms.dashboard import DashboardPage
from common.test.acceptance.tests.helpers import UniqueCourseTest, generate_course_key
DEFAULT_SHORT_DATE_FORMAT = '{dt:%b} {dt.day}, {dt.year}'
TEST_DATE_FORMAT = '{dt:%b} {dt.day}, {dt.year} {dt.hour:02}:{dt.minute:02}'
DEFAULT_SHORT_DATE_FORMAT = u'{dt:%b} {dt.day}, {dt.year}'
TEST_DATE_FORMAT = u'{dt:%b} {dt.day}, {dt.year} {dt.hour:02}:{dt.minute:02}'
class BaseLmsDashboardTest(UniqueCourseTest):
@@ -201,7 +201,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
self.course_fixture.configure_course()
end_date = DEFAULT_SHORT_DATE_FORMAT.format(dt=course_end_date)
expected_course_date = "Ended - {end_date}".format(end_date=end_date)
expected_course_date = u"Ended - {end_date}".format(end_date=end_date)
# reload the page for changes to course date changes to appear in dashboard
self.dashboard_page.visit()
@@ -234,7 +234,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
self.course_fixture.configure_course()
start_date = DEFAULT_SHORT_DATE_FORMAT.format(dt=course_start_date)
expected_course_date = "Started - {start_date}".format(start_date=start_date)
expected_course_date = u"Started - {start_date}".format(start_date=start_date)
# reload the page for changes to course date changes to appear in dashboard
self.dashboard_page.visit()
@@ -267,7 +267,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
self.course_fixture.configure_course()
start_date = DEFAULT_SHORT_DATE_FORMAT.format(dt=course_start_date)
expected_course_date = "Starts - {start_date}".format(start_date=start_date)
expected_course_date = u"Starts - {start_date}".format(start_date=start_date)
# reload the page for changes to course date changes to appear in dashboard
self.dashboard_page.visit()
@@ -301,7 +301,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
self.course_fixture.configure_course()
start_date = TEST_DATE_FORMAT.format(dt=course_start_date)
expected_course_date = "Starts - {start_date} UTC".format(start_date=start_date)
expected_course_date = u"Starts - {start_date} UTC".format(start_date=start_date)
# reload the page for changes to course date changes to appear in dashboard
self.dashboard_page.visit()
@@ -338,7 +338,7 @@ class LmsDashboardPageTest(BaseLmsDashboardTest):
})
self.course_fixture._add_advanced_settings()
expected_course_date = "Starts - {start_date}".format(start_date=course_advertised_start)
expected_course_date = u"Starts - {start_date}".format(start_date=course_advertised_start)
self.dashboard_page.visit()
course_date = self.dashboard_page.get_course_date()

View File

@@ -59,14 +59,14 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 2",
data="""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
data=u"""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
),
),
XBlockFixtureDesc("vertical", "Test Unit 2").add_children(
XBlockFixtureDesc(
"html",
"Test HTML 3",
data="""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
data=u"""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
),
),
),
@@ -75,7 +75,7 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 4",
data="""
data=u"""
<p><span class="{}">Annotate this!</span></p>
""".format(self.selector)
),
@@ -88,14 +88,14 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 5",
data="""
data=u"""
<p><span class="{}">Annotate this!</span></p>
""".format(self.selector)
),
XBlockFixtureDesc(
"html",
"Test HTML 6",
data="""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
data=u"""<p><span class="{}">Annotate this!</span></p>""".format(self.selector)
),
),
),
@@ -132,7 +132,7 @@ class EdxNotesDefaultInteractionsTest(EdxNotesTestMixin):
index = offset
for component in components:
for note in component.create_note(".{}".format(self.selector)):
note.text = "TEST TEXT {}".format(index)
note.text = u"TEST TEXT {}".format(index)
index += 1
def edit_notes(self, components, offset=0):
@@ -141,7 +141,7 @@ class EdxNotesDefaultInteractionsTest(EdxNotesTestMixin):
for component in components:
self.assertGreater(len(component.notes), 0)
for note in component.edit_note():
note.text = "TEST TEXT {}".format(index)
note.text = u"TEST TEXT {}".format(index)
index += 1
def edit_tags_in_notes(self, components, tags):
@@ -166,7 +166,7 @@ class EdxNotesDefaultInteractionsTest(EdxNotesTestMixin):
def assert_text_in_notes(self, notes):
actual = [note.text for note in notes]
expected = ["TEST TEXT {}".format(i) for i in xrange(len(notes))]
expected = [u"TEST TEXT {}".format(i) for i in xrange(len(notes))]
self.assertEqual(expected, actual)
def assert_tags_in_notes(self, notes, expected_tags):

View File

@@ -999,7 +999,7 @@ class CertificatesTest(BaseInstructorDashboardTest):
self.certificates_section.add_certificate_exception(self.user_name, '')
self.assertIn(
'{user} already in exception list.'.format(user=self.user_name),
u'{user} already in exception list.'.format(user=self.user_name),
self.certificates_section.message.text
)
@@ -1046,7 +1046,7 @@ class CertificatesTest(BaseInstructorDashboardTest):
self.certificates_section.wait_for_ajax()
self.assertIn(
"{user} does not exist in the LMS. Please check your spelling and retry.".format(user=invalid_user),
u"{user} does not exist in the LMS. Please check your spelling and retry.".format(user=invalid_user),
self.certificates_section.message.text
)
@@ -1079,7 +1079,7 @@ class CertificatesTest(BaseInstructorDashboardTest):
self.certificates_section.wait_for_ajax()
self.assertIn(
"{user} is not enrolled in this course. Please check your spelling and retry.".format(user=new_user),
u"{user} is not enrolled in this course. Please check your spelling and retry.".format(user=new_user),
self.certificates_section.message.text
)
@@ -1217,7 +1217,7 @@ class CertificateInvalidationTest(BaseInstructorDashboardTest):
# Validate success message
self.assertIn(
"Certificate has been successfully invalidated for {user}.".format(user=self.student_name),
u"Certificate has been successfully invalidated for {user}.".format(user=self.student_name),
self.certificates_section.certificate_invalidation_message.text
)

View File

@@ -21,7 +21,7 @@ class MatlabProblemTest(ProblemsTest):
"""
Create a matlab problem for the test.
"""
problem_data = dedent("""
problem_data = dedent(u"""
<problem markdown="null">
<text>
<p>

View File

@@ -76,7 +76,7 @@ class ProblemClarificationTest(ProblemsTest):
"""
Create a problem with a <clarification>
"""
xml = dedent("""
xml = dedent(u"""
<problem markdown="null">
<text>
<p>
@@ -705,7 +705,7 @@ class ProblemQuestionDescriptionTest(ProblemsTest):
"""
Create a problem with question and description.
"""
xml = dedent("""
xml = dedent(u"""
<problem>
<choiceresponse>
<label>Eggplant is a _____?</label>

View File

@@ -51,7 +51,7 @@ class ProblemTypeTestBaseMeta(ABCMeta):
]
for required_attr in required_attrs:
msg = ('{} is a required attribute for {}').format(
msg = (u'{} is a required attribute for {}').format(
required_attr, str(cls)
)
@@ -126,7 +126,7 @@ class ProblemTypeTestBase(ProblemsTest, EventsTestMixin):
Args:
status: one of ("correct", "incorrect", "unanswered", "submitted")
"""
msg = "Wait for status to be {}".format(status)
msg = u"Wait for status to be {}".format(status)
selector = ', '.join(self.status_indicators[status])
self.problem_page.wait_for_element_visibility(selector, msg)
@@ -536,9 +536,9 @@ class ProblemNeverShowCorrectnessMixin(object):
# Problem progress text depends on points possible
possible = 'possible (ungraded, results hidden)'
if self.problem_points == 1:
problem_progress = '1 point {}'.format(possible)
problem_progress = u'1 point {}'.format(possible)
else:
problem_progress = '{} points {}'.format(self.problem_points, possible)
problem_progress = u'{} points {}'.format(self.problem_points, possible)
# Make sure we're looking at the right problem
self.problem_page.wait_for(
@@ -994,7 +994,7 @@ class MultipleChoiceProblemTypeTestMultipleAttempt(MultipleChoiceProblemTypeBase
for attempts_used in range(3):
self.assertEqual(
self.problem_page.submission_feedback,
"You have used {} of 3 attempts".format(str(attempts_used)),
u"You have used {} of 3 attempts".format(str(attempts_used)),
"All 3 attempts are not available"
)
if attempts_used == 2:
@@ -1777,7 +1777,7 @@ class ChoiceTextProblemTypeTestBase(ProblemTypeTestBase):
Selects the nth (where n == input_num) choice of the problem.
"""
self.problem_page.q(
css='div.problem input.ctinput[type="{}"]'.format(self.choice_type)
css=u'div.problem input.ctinput[type="{}"]'.format(self.choice_type)
).nth(input_num).click()
def _fill_input_text(self, value, input_num):

View File

@@ -372,8 +372,7 @@ class SubsectionGradingPolicyA11yTest(SubsectionGradingPolicyBase):
# Verify that y-Axis labels are aria-hidden
self.assertEqual(['100%', 'true'], self.progress_page.y_tick_label(0))
self.assertEqual(['0%', 'true'], self.progress_page.y_tick_label(1))
self.assertEqual(['Pass 50%', 'true'], self.progress_page.y_tick_label(2))
self.assertEqual(['Pass 50%', 'true'], self.progress_page.y_tick_label(2)) # pylint: disable=unicode-format-string,line-too-long
# Verify x-Axis labels and sr-text
self._check_tick_text(0, [u'Homework 1 - Test Subsection 1 - 50% (1/2)'], u'HW 01')
@@ -434,7 +433,7 @@ class SubsectionGradingPolicyA11yTest(SubsectionGradingPolicyBase):
# Verify the overall score. The first element in the array is the sr-only text, and the
# second is the total text (including the sr-only text).
self.assertEqual(['Overall Score', 'Overall Score\n2%'], self.progress_page.graph_overall_score())
self.assertEqual(['Overall Score', 'Overall Score\n2%'], self.progress_page.graph_overall_score()) # pylint: disable=unicode-format-string,line-too-long
class ProgressPageA11yTest(ProgressPageBaseTest):

View File

@@ -56,8 +56,8 @@ class TeamsTabBase(EventsTestMixin, ForumsConfigMixin, UniqueCourseTest):
team = {
'course_id': self.course_id,
'topic_id': topic['id'],
'name': 'Team {}'.format(i),
'description': 'Description {}'.format(i),
'name': u'Team {}'.format(i),
'description': u'Description {}'.format(i),
'language': 'aa',
'country': 'AF'
}
@@ -623,7 +623,7 @@ class BrowseTeamsWithinTopicTest(TeamsTabBase):
self.assertEqual(search_results_page.header_name, 'Team Search')
self.assertEqual(
search_results_page.header_description,
'Showing results for "{search_query}"'.format(search_query=search_query)
u'Showing results for "{search_query}"'.format(search_query=search_query)
)
def verify_on_page(self, teams_page, page_num, total_teams, pagination_header_text, footer_visible):
@@ -916,7 +916,7 @@ class TeamFormActions(TeamsTabBase):
title='Create a New Team',
description='Create a new team if you can\'t find an existing team to join, '
'or if you would like to learn with friends you know.',
breadcrumbs='All Topics {topic_name}'.format(topic_name=self.topic['name'])
breadcrumbs=u'All Topics {topic_name}'.format(topic_name=self.topic['name'])
)
def verify_and_navigate_to_edit_team_page(self):
@@ -933,7 +933,7 @@ class TeamFormActions(TeamsTabBase):
title='Edit Team',
description='If you make significant changes, make sure you notify '
'members of the team before making these changes.',
breadcrumbs='All Topics {topic_name} {team_name}'.format(
breadcrumbs=u'All Topics {topic_name} {team_name}'.format(
topic_name=self.topic['name'],
team_name=self.team['name']
)

View File

@@ -144,7 +144,7 @@ class StudioLibraryTest(AcceptanceTest):
fixture = LibraryFixture(
'test_org',
self.unique_id,
'Test Library {}'.format(self.unique_id),
u'Test Library {}'.format(self.unique_id),
)
self.populate_library_fixture(fixture)
fixture.install()

View File

@@ -48,7 +48,7 @@ class NestedVerticalTest(ContainerBase):
self.group_a_item_1_action_index = 0
self.group_a_item_2_action_index = 1
self.duplicate_label = "Duplicate of '{0}'"
self.duplicate_label = u"Duplicate of '{0}'"
self.discussion_label = "Discussion"
course_fixture.add_children(
@@ -286,7 +286,7 @@ class BaseGroupConfigurationsTest(ContainerBase):
self.assertEqual("Access is not restricted", visibility_editor.current_groups_message)
else:
self.assertEqual(
"Access is restricted to: {groups}".format(groups=expected_current_groups),
u"Access is restricted to: {groups}".format(groups=expected_current_groups),
visibility_editor.current_groups_message
)
@@ -1236,8 +1236,8 @@ class MoveComponentTest(ContainerBase):
}
self.source_component_display_name = 'HTML 11'
self.source_xblock_category = 'component'
self.message_move = 'Success! "{display_name}" has been moved.'
self.message_undo = 'Move cancelled. "{display_name}" has been moved back to its original location.'
self.message_move = u'Success! "{display_name}" has been moved.'
self.message_undo = u'Move cancelled. "{display_name}" has been moved back to its original location.'
def populate_course_fixture(self, course_fixture):
"""

View File

@@ -141,7 +141,7 @@ class GradingPageTest(StudioCourseTest):
self.assertIn(
'0-3',
grade_ranges,
'expected range: 0-3, not found in grade ranges:{}'.format(grade_ranges)
u'expected range: 0-3, not found in grade ranges:{}'.format(grade_ranges)
)
def test_settings_are_persisted_on_save_only(self):

View File

@@ -150,7 +150,7 @@ class HTMLComponentEditorTests(ContainerBase):
--></style>
""
"""
content = '<p class="title">pages</p><style><!-- .title { color: red; } --></style>'
content = u'<p class="title">pages</p><style><!-- .title { color: red; } --></style>'
# Add HTML Text type component
self._add_component('Text')

View File

@@ -218,8 +218,8 @@ class StudioLibraryContainerTest(StudioLibraryTest, UniqueCourseTest, TestWithSe
And I set Problem Type selector so "Any"
Then I can see that "No matching content" warning is shown
"""
expected_tpl = "The specified library is configured to fetch {count} problems, " \
"but there are only {actual} matching problems."
expected_tpl = u"The specified library is configured to fetch {count} problems, " \
u"but there are only {actual} matching problems."
library_container = self._get_library_xblock_wrapper(self.unit_page.xblocks[1])

View File

@@ -43,9 +43,9 @@ class CertificatesTest(StudioCourseTest):
Makes signatory dict which can be used in the tests to create certificates
"""
return {
'name': '{prefix} Signatory Name'.format(prefix=prefix),
'title': '{prefix} Signatory Title'.format(prefix=prefix),
'organization': '{prefix} Signatory Organization'.format(prefix=prefix),
'name': u'{prefix} Signatory Name'.format(prefix=prefix),
'title': u'{prefix} Signatory Title'.format(prefix=prefix),
'organization': u'{prefix} Signatory Organization'.format(prefix=prefix),
}
def create_and_verify_certificate(self, course_title_override, existing_certs, signatories):

View File

@@ -106,7 +106,7 @@ class PagesTest(StudioCourseTest):
self.assertEqual(
static_tab_titles,
['Empty', 'First'],
'Order should be:["Empty", "First] but getting {} from the page'.format(static_tab_titles)
u'Order should be:["Empty", "First] but getting {} from the page'.format(static_tab_titles)
)
def test_user_can_reorder_builtin_tabs(self):

View File

@@ -28,14 +28,14 @@ class AnnotatableProblemTest(UniqueCourseTest):
USERNAME = "STAFF_TESTER"
EMAIL = "johndoe@example.com"
DATA_TEMPLATE = dedent("""\
DATA_TEMPLATE = dedent(u"""\
<annotatable>
<instructions>Instruction text</instructions>
<p>{}</p>
</annotatable>
""")
ANNOTATION_TEMPLATE = dedent("""\
ANNOTATION_TEMPLATE = dedent(u"""\
Before {0}.
<annotation title="region {0}" body="Comment {0}" highlight="yellow" problem="{0}">
Region Contents {0}
@@ -43,7 +43,7 @@ class AnnotatableProblemTest(UniqueCourseTest):
After {0}.
""")
PROBLEM_TEMPLATE = dedent("""\
PROBLEM_TEMPLATE = dedent(u"""\
<problem max_attempts="1" weight="">
<annotationresponse>
<annotationinput>
@@ -63,7 +63,7 @@ class AnnotatableProblemTest(UniqueCourseTest):
</problem>
""")
OPTION_TEMPLATE = """<option choice="{correctness}">{number}</option>"""
OPTION_TEMPLATE = u"""<option choice="{correctness}">{number}</option>"""
def setUp(self):
super(AnnotatableProblemTest, self).setUp()

View File

@@ -46,10 +46,10 @@ class VideoEventsTestMixin(EventsTestMixin, VideoBaseTest):
def assert_field_type(self, event_dict, field, field_type):
"""Assert that a particular `field` in the `event_dict` has a particular type"""
self.assertIn(field, event_dict, '{0} not found in the root of the event'.format(field))
self.assertIn(field, event_dict, u'{0} not found in the root of the event'.format(field))
self.assertTrue(
isinstance(event_dict[field], field_type),
'Expected "{key}" to be a "{field_type}", but it has the value "{value}" of type "{t}"'.format(
u'Expected "{key}" to be a "{field_type}", but it has the value "{value}" of type "{t}"'.format(
key=field,
value=event_dict[field],
t=type(event_dict[field]),
@@ -123,7 +123,7 @@ class VideoEventsTest(VideoEventsTestMixin):
)
for field in dynamic_string_fields:
self.assert_field_type(load_video_event, field, basestring)
self.assertIn(field, load_video_event, '{0} not found in the root of the event'.format(field))
self.assertIn(field, load_video_event, u'{0} not found in the root of the event'.format(field))
del load_video_event[field]
# A weak assertion for the timestamp as well
@@ -360,7 +360,7 @@ class VideoBumperEventsTest(VideoEventsTestMixin):
)
for field in dynamic_string_fields:
self.assert_field_type(load_video_event, field, basestring)
self.assertIn(field, load_video_event, '{0} not found in the root of the event'.format(field))
self.assertIn(field, load_video_event, u'{0} not found in the root of the event'.format(field))
del load_video_event[field]
# A weak assertion for the timestamp as well

View File

@@ -128,7 +128,7 @@ class VideoBaseTest(UniqueCourseTest):
:param vertical_index: index for the vertical display name
:return: XBlockFixtureDesc
"""
xblock_course_vertical = XBlockFixtureDesc('vertical', 'Test Vertical-{0}'.format(vertical_index))
xblock_course_vertical = XBlockFixtureDesc('vertical', u'Test Vertical-{0}'.format(vertical_index))
for video in vertical_contents:
xblock_course_vertical.add_children(
@@ -1202,8 +1202,8 @@ class HLSVideoTest(VideoBaseTest):
for line_no in range(5):
self.video.click_transcript_line(line_no=line_no)
self.video.wait_for_position('0:0{}'.format(line_no))
self.video.wait_for_position(u'0:0{}'.format(line_no))
for line_no in range(5):
self.video.seek('0:0{}'.format(line_no))
self.assertEqual(self.video.active_caption_text, 'Hi, edX welcomes you{}.'.format(line_no))
self.video.seek(u'0:0{}'.format(line_no))
self.assertEqual(self.video.active_caption_text, u'Hi, edX welcomes you{}.'.format(line_no))