diff --git a/common/djangoapps/entitlements/models.py b/common/djangoapps/entitlements/models.py
index 71ebf29af6..ba39546b09 100644
--- a/common/djangoapps/entitlements/models.py
+++ b/common/djangoapps/entitlements/models.py
@@ -386,7 +386,7 @@ class CourseEntitlement(TimeStampedModel):
mode=entitlement.mode
)
except CourseEnrollmentException:
- log.exception('Login for Course Entitlement {uuid} failed'.format(uuid=entitlement.uuid))
+ log.exception(u'Login for Course Entitlement {uuid} failed'.format(uuid=entitlement.uuid))
return False
entitlement.set_enrollment(enrollment)
@@ -432,7 +432,7 @@ class CourseEntitlement(TimeStampedModel):
if not refund_successful:
# This state is achieved in most cases by a failure in the ecommerce service to process the refund.
log.warn(
- 'Entitlement Refund failed for Course Entitlement [%s], alert User',
+ u'Entitlement Refund failed for Course Entitlement [%s], alert User',
self.uuid
)
# Force Transaction reset with an Integrity error exception, this will revert all previous transactions
diff --git a/common/djangoapps/entitlements/utils.py b/common/djangoapps/entitlements/utils.py
index 84b5c5b13f..ce86389c18 100644
--- a/common/djangoapps/entitlements/utils.py
+++ b/common/djangoapps/entitlements/utils.py
@@ -36,8 +36,8 @@ def is_course_run_entitlement_fulfillable(
try:
course_overview = CourseOverview.get_from_id(course_run_key)
except CourseOverview.DoesNotExist:
- log.error(('There is no CourseOverview entry available for {course_run_id}, '
- 'course run cannot be applied to entitlement').format(
+ log.error((u'There is no CourseOverview entry available for {course_run_id}, '
+ u'course run cannot be applied to entitlement').format(
course_run_id=str(course_run_key)
))
return False
diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py
index 7dd29304f9..002293c912 100644
--- a/common/djangoapps/student/tests/test_email.py
+++ b/common/djangoapps/student/tests/test_email.py
@@ -104,7 +104,7 @@ class ActivationEmailTests(CacheIsolationTestCase):
u"high-quality {platform} courses".format(platform=settings.PLATFORM_NAME),
"http://edx.org/activate/",
(
- "please use our web form at "
+ u"please use our web form at "
u"{support_url} ".format(support_url=settings.SUPPORT_SITE_LINK)
)
]
diff --git a/common/djangoapps/third_party_auth/admin.py b/common/djangoapps/third_party_auth/admin.py
index 4387a26c3c..a3b527b149 100644
--- a/common/djangoapps/third_party_auth/admin.py
+++ b/common/djangoapps/third_party_auth/admin.py
@@ -151,10 +151,10 @@ class SAMLConfigurationAdmin(KeyedConfigurationModelAdmin):
public_key = inst.get_setting('SP_PUBLIC_CERT')
private_key = inst.get_setting('SP_PRIVATE_KEY')
if not public_key or not private_key:
- return u'Key pair incomplete/missing'
+ return HTML(u'Key pair incomplete/missing')
pub1, pub2 = public_key[0:10], public_key[-10:]
priv1, priv2 = private_key[0:10], private_key[-10:]
- return u'Public: {}…{} Private: {}…{}'.format(pub1, pub2, priv1, priv2)
+ return HTML(u'Public: {}…{} Private: {}…{}').format(pub1, pub2, priv1, priv2)
key_summary.allow_tags = True
admin.site.register(SAMLConfiguration, SAMLConfigurationAdmin)
@@ -210,7 +210,7 @@ class ApiPermissionsAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ApiPermissionsAdminForm, self).__init__(*args, **kwargs)
self.fields['provider_id'].choices = (
- (provider.provider_id, "{} ({})".format(provider.name, provider.provider_id))
+ (provider.provider_id, u"{} ({})".format(provider.name, provider.provider_id))
for provider in Registry.enabled()
)
diff --git a/common/djangoapps/third_party_auth/api/tests/test_views.py b/common/djangoapps/third_party_auth/api/tests/test_views.py
index cb5e15aef9..36eb21c515 100644
--- a/common/djangoapps/third_party_auth/api/tests/test_views.py
+++ b/common/djangoapps/third_party_auth/api/tests/test_views.py
@@ -259,7 +259,7 @@ class UserMappingViewAPITests(TpaAPITestCase):
if access_token == 'valid-token':
access_token = token.token
- response = self.client.get(url, HTTP_AUTHORIZATION='Bearer {}'.format(access_token))
+ response = self.client.get(url, HTTP_AUTHORIZATION=u'Bearer {}'.format(access_token))
self._verify_response(response, expect_code, expect_data)
@ddt.data(
diff --git a/common/djangoapps/third_party_auth/api/views.py b/common/djangoapps/third_party_auth/api/views.py
index 5004a65369..7481057228 100644
--- a/common/djangoapps/third_party_auth/api/views.py
+++ b/common/djangoapps/third_party_auth/api/views.py
@@ -117,7 +117,7 @@ class BaseUserView(APIView):
if identifier.kind not in self.identifier_kinds:
# This is already checked before we get here, so raise a 500 error
# if the check fails.
- raise ValueError("Identifier kind {} not in {}".format(identifier.kind, self.identifier_kinds))
+ raise ValueError(u"Identifier kind {} not in {}".format(identifier.kind, self.identifier_kinds))
self_request = False
if identifier == self.identifier('username', request.user.username):
diff --git a/common/djangoapps/third_party_auth/lti.py b/common/djangoapps/third_party_auth/lti.py
index c383506712..f6bd4a87a0 100644
--- a/common/djangoapps/third_party_auth/lti.py
+++ b/common/djangoapps/third_party_auth/lti.py
@@ -186,7 +186,7 @@ class LTIAuthBackend(BaseAuth):
if valid:
return data
except AttributeError as error:
- log.error("'{}' not found.".format(text_type(error)))
+ log.error(u"'{}' not found.".format(text_type(error)))
return None
@classmethod
diff --git a/common/djangoapps/third_party_auth/management/commands/saml.py b/common/djangoapps/third_party_auth/management/commands/saml.py
index b126a2b649..8717162a01 100644
--- a/common/djangoapps/third_party_auth/management/commands/saml.py
+++ b/common/djangoapps/third_party_auth/management/commands/saml.py
@@ -27,10 +27,10 @@ class Command(BaseCommand):
log.addHandler(log_handler)
total, skipped, attempted, updated, failed, failure_messages = fetch_saml_metadata()
self.stdout.write(
- "\nDone."
- "\n{total} provider(s) found in database."
- "\n{skipped} skipped and {attempted} attempted."
- "\n{updated} updated and {failed} failed.\n".format(
+ u"\nDone."
+ u"\n{total} provider(s) found in database."
+ u"\n{skipped} skipped and {attempted} attempted."
+ u"\n{updated} updated and {failed} failed.\n".format(
total=total,
skipped=skipped, attempted=attempted,
updated=updated, failed=failed,
@@ -39,7 +39,7 @@ class Command(BaseCommand):
if failed > 0:
raise CommandError(
- "Command finished with the following exceptions:\n\n{failures}".format(
+ u"Command finished with the following exceptions:\n\n{failures}".format(
failures="\n\n".join(failure_messages)
)
)
diff --git a/common/djangoapps/third_party_auth/models.py b/common/djangoapps/third_party_auth/models.py
index 5eb1512fa5..9adbac3c34 100644
--- a/common/djangoapps/third_party_auth/models.py
+++ b/common/djangoapps/third_party_auth/models.py
@@ -18,7 +18,6 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from provider.oauth2.models import Client
from provider.utils import long_token
-from six import text_type
from social_core.backends.base import BaseAuth
from social_core.backends.oauth import OAuthAuth
from social_core.backends.saml import SAMLAuth
@@ -61,9 +60,9 @@ def clean_json(value, of_type):
try:
value_python = json.loads(value)
except ValueError as err:
- raise ValidationError("Invalid JSON: {}".format(text_type(err)))
+ raise ValidationError(u"Invalid JSON: {}".format(err))
if not isinstance(value_python, of_type):
- raise ValidationError("Expected a JSON {}".format(of_type))
+ raise ValidationError(u"Expected a JSON {}".format(of_type))
return json.dumps(value_python, indent=4)
@@ -345,7 +344,7 @@ class OAuth2ProviderConfig(ProviderConfig):
help_text=(
'For increased security, you can avoid storing this in your database by leaving '
' this field blank and setting '
- 'SOCIAL_AUTH_OAUTH_SECRETS = {"(backend name)": "secret", ...} '
+ 'SOCIAL_AUTH_OAUTH_SECRETS = {"(backend name)": "secret", ...} ' # pylint: disable=unicode-format-string
'in your instance\'s Django settings (or lms.auth.json)'
)
)
@@ -444,7 +443,7 @@ class SAMLConfiguration(ConfigurationModel):
"""
Return human-readable string representation.
"""
- return "SAMLConfiguration {site}: {slug} on {date:%Y-%m-%d %H:%M:%S}".format(
+ return u"SAMLConfiguration {site}: {slug} on {date:%Y-%m-%d %H:%M:%S}".format(
site=self.site.name,
slug=self.slug,
date=self.change_date,
@@ -475,7 +474,7 @@ class SAMLConfiguration(ConfigurationModel):
""" Get the value of a setting, or raise KeyError """
default_saml_contact = {
# Default contact information to put into the SAML metadata that gets generated by python-saml.
- "givenName": _("{platform_name} Support").format(
+ "givenName": _(u"{platform_name} Support").format(
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
),
"emailAddress": configuration_helpers.get_value('TECH_SUPPORT_EMAIL', settings.TECH_SUPPORT_EMAIL),
@@ -594,9 +593,9 @@ class SAMLProviderConfig(ProviderConfig):
verbose_name="Advanced settings", blank=True,
help_text=(
'For advanced use cases, enter a JSON object with addtional configuration. '
- 'The tpa-saml backend supports {"requiredEntitlements": ["urn:..."]}, '
+ 'The tpa-saml backend supports {"requiredEntitlements": ["urn:..."]}, ' # pylint: disable=unicode-format-string
'which can be used to require the presence of a specific eduPersonEntitlement, '
- 'and {"extra_field_definitions": [{"name": "...", "urn": "..."},...]}, which can be '
+ 'and {"extra_field_definitions": [{"name": "...", "urn": "..."},...]}, which can be ' # pylint: disable=unicode-format-string,line-too-long
'used to define registration form fields and the URNs that can be used to retrieve '
'the relevant values from the SAML response. Custom provider types, as selected '
'in the "Identity Provider Type" field, may make use of the information stored '
@@ -683,7 +682,7 @@ class SAMLProviderConfig(ProviderConfig):
data = SAMLProviderData.current(self.entity_id)
if not data or not data.is_valid():
log.error(
- 'No SAMLProviderData found for provider "%s" with entity id "%s" and IdP slug "%s". '
+ 'No SAMLProviderData found for provider "%s" with entity id "%s" and IdP slug "%s". ' # pylint: disable=unicode-format-string,line-too-long
'Run "manage.py saml pull" to fix or debug.',
self.name, self.entity_id, self.slug
)
@@ -794,7 +793,7 @@ class LTIProviderConfig(ProviderConfig):
'tool consumer instance should know this value. '
'For increased security, you can avoid storing this in '
'your database by leaving this field blank and setting '
- 'SOCIAL_AUTH_LTI_CONSUMER_SECRETS = {"consumer key": "secret", ...} '
+ 'SOCIAL_AUTH_LTI_CONSUMER_SECRETS = {"consumer key": "secret", ...} ' # pylint: disable=unicode-format-string,line-too-long
'in your instance\'s Django setttigs (or lms.auth.json)'
),
blank=True,
diff --git a/common/djangoapps/third_party_auth/pipeline.py b/common/djangoapps/third_party_auth/pipeline.py
index 4a40148634..583791b764 100644
--- a/common/djangoapps/third_party_auth/pipeline.py
+++ b/common/djangoapps/third_party_auth/pipeline.py
@@ -275,7 +275,7 @@ def _get_enabled_provider(provider_id):
enabled_provider = provider.Registry.get(provider_id)
if not enabled_provider:
- raise ValueError('Provider %s not enabled' % provider_id)
+ raise ValueError(u'Provider %s not enabled' % provider_id)
return enabled_provider
@@ -317,7 +317,7 @@ def get_complete_url(backend_name):
ValueError: if no provider is enabled with the given backend_name.
"""
if not any(provider.Registry.get_enabled_by_backend_name(backend_name)):
- raise ValueError('Provider with backend %s not enabled' % backend_name)
+ raise ValueError(u'Provider with backend %s not enabled' % backend_name)
return _get_url('social:complete', backend_name)
@@ -593,7 +593,7 @@ def ensure_user_information(strategy, auth_entry, backend=None, user=None, socia
# register anew via SSO. See SOL-1324 in JIRA.
# However, we will log a warning for this case:
logger.warning(
- 'User "%s" is using third_party_auth to login but has not yet activated their account. ',
+ u'User "%s" is using third_party_auth to login but has not yet activated their account. ',
user.username
)
@@ -727,8 +727,8 @@ def user_details_force_sync(auth_entry, strategy, details, user=None, *args, **k
current_value = getattr(model, field)
if provider_value is not None and current_value != provider_value:
if field in integrity_conflict_fields and User.objects.filter(**{field: provider_value}).exists():
- logger.warning('User with ID [%s] tried to synchronize profile data through [%s] '
- 'but there was a conflict with an existing [%s]: [%s].',
+ logger.warning(u'User with ID [%s] tried to synchronize profile data through [%s] '
+ u'but there was a conflict with an existing [%s]: [%s].',
user.id, current_provider.name, field, provider_value)
continue
changed[provider_field] = current_value
@@ -736,8 +736,8 @@ def user_details_force_sync(auth_entry, strategy, details, user=None, *args, **k
if changed:
logger.info(
- "User [%s] performed SSO through [%s] who synchronizes profile data, and the "
- "following fields were changed: %s", user.username, current_provider.name, changed.keys(),
+ u"User [%s] performed SSO through [%s] who synchronizes profile data, and the "
+ u"following fields were changed: %s", user.username, current_provider.name, changed.keys(),
)
# Save changes to user and user.profile models.
@@ -763,7 +763,7 @@ def user_details_force_sync(auth_entry, strategy, details, user=None, *args, **k
email.send()
except SMTPException:
logger.exception('Error sending IdP learner data sync-initiated email change '
- 'notification email for user [%s].', user.username)
+ u'notification email for user [%s].', user.username)
def set_id_verification_status(auth_entry, strategy, details, user=None, *args, **kwargs):
diff --git a/common/djangoapps/third_party_auth/saml.py b/common/djangoapps/third_party_auth/saml.py
index d2ea612459..8e5918575a 100644
--- a/common/djangoapps/third_party_auth/saml.py
+++ b/common/djangoapps/third_party_auth/saml.py
@@ -155,7 +155,7 @@ class SAMLAuthBackend(SAMLAuth): # pylint: disable=abstract-method
for expected in idp.conf['requiredEntitlements']:
if expected not in entitlements:
log.warning(
- "SAML user from IdP %s rejected due to missing eduPersonEntitlement %s", idp.name, expected)
+ u"SAML user from IdP %s rejected due to missing eduPersonEntitlement %s", idp.name, expected)
raise AuthForbidden(self)
def _create_saml_auth(self, idp):
@@ -177,7 +177,7 @@ class SAMLAuthBackend(SAMLAuth): # pylint: disable=abstract-method
def wrapped_method(*args, **kwargs):
""" Wrapped login or process_response method """
result = method(*args, **kwargs)
- log.info("SAML login %s for IdP %s. XML is:\n%s", action_description, idp.name, xml_getter())
+ log.info(u"SAML login %s for IdP %s. XML is:\n%s", action_description, idp.name, xml_getter())
return result
setattr(auth_inst, method_name, wrapped_method)
@@ -363,8 +363,8 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
if not all(var in self.conf for var in self.required_variables):
missing = [var for var in self.required_variables if var not in self.conf]
log.warning(
- "To retrieve rich user data for an SAP SuccessFactors identity provider, the following keys in "
- "'other_settings' are required, but were missing: %s",
+ u"To retrieve rich user data for an SAP SuccessFactors identity provider, the following keys in "
+ u"'other_settings' are required, but were missing: %s",
missing
)
return missing
@@ -381,14 +381,14 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
token_data = transaction_data.get('token_data')
token_data = token_data if token_data else 'Not available'
log_msg_template = (
- 'SAPSuccessFactors exception received for {operation_name} request. ' +
- 'URL: {url} ' +
- 'Company ID: {company_id}. ' +
- 'User ID: {user_id}. ' +
- 'Error message: {err_msg}. ' +
- 'System message: {sys_msg}. ' +
- 'Headers: {headers}. ' +
- 'Token Data: {token_data}.'
+ u'SAPSuccessFactors exception received for {operation_name} request. ' +
+ u'URL: {url} ' +
+ u'Company ID: {company_id}. ' +
+ u'User ID: {user_id}. ' +
+ u'Error message: {err_msg}. ' +
+ u'System message: {sys_msg}. ' +
+ u'Headers: {headers}. ' +
+ u'Token Data: {token_data}.'
)
log_msg = log_msg_template.format(
operation_name=transaction_data['operation_name'],
@@ -469,7 +469,7 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
if not access_token_data:
return None
token_string = access_token_data['access_token']
- session.headers.update({'Authorization': 'Bearer {}'.format(token_string), 'Accept': 'application/json'})
+ session.headers.update({'Authorization': u'Bearer {}'.format(token_string), 'Accept': 'application/json'})
session.token_data = access_token_data
return session
@@ -537,7 +537,7 @@ def get_saml_idp_class(idp_identifier_string):
}
if idp_identifier_string not in choices:
log.error(
- '%s is not a valid EdXSAMLIdentityProvider subclass; using EdXSAMLIdentityProvider base class.',
+ u'%s is not a valid EdXSAMLIdentityProvider subclass; using EdXSAMLIdentityProvider base class.',
idp_identifier_string
)
return choices.get(idp_identifier_string, EdXSAMLIdentityProvider)
diff --git a/common/djangoapps/third_party_auth/tasks.py b/common/djangoapps/third_party_auth/tasks.py
index ad19eda2be..02fb0b53d7 100644
--- a/common/djangoapps/third_party_auth/tasks.py
+++ b/common/djangoapps/third_party_auth/tasks.py
@@ -17,6 +17,7 @@ from requests import exceptions
from six import text_type
from third_party_auth.models import SAMLConfiguration, SAMLProviderConfig, SAMLProviderData
+from openedx.core.djangolib.markup import Text
log = logging.getLogger(__name__)
@@ -76,9 +77,9 @@ def fetch_saml_metadata():
failure_messages = [] # We return the length of this array for num_failed
for url, entity_ids in url_map.items():
try:
- log.info("Fetching %s", url)
+ log.info(u"Fetching %s", url)
if not url.lower().startswith('https'):
- log.warning("This SAML metadata URL is not secure! It should use HTTPS. (%s)", url)
+ log.warning(u"This SAML metadata URL is not secure! It should use HTTPS. (%s)", url)
response = requests.get(url, verify=True) # May raise HTTPError or SSLError or ConnectionError
response.raise_for_status() # May raise an HTTPError
@@ -108,23 +109,23 @@ def fetch_saml_metadata():
log.exception(text_type(error))
failure_messages.append(
- "{error_type}: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
+ u"{error_type}: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
error_type=type(error).__name__,
error_message=text_type(error),
url=url,
entity_ids="\n".join(
- ["\t{}: {}".format(count, item) for count, item in enumerate(entity_ids, start=1)],
+ [u"\t{}: {}".format(count, item) for count, item in enumerate(entity_ids, start=1)],
)
)
)
except etree.XMLSyntaxError as error:
log.exception(text_type(error))
failure_messages.append(
- "XMLSyntaxError: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
+ u"XMLSyntaxError: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
error_message=str(error.error_log),
url=url,
entity_ids="\n".join(
- ["\t{}: {}".format(count, item) for count, item in enumerate(entity_ids, start=1)],
+ [u"\t{}: {}".format(count, item) for count, item in enumerate(entity_ids, start=1)],
)
)
)
@@ -144,12 +145,12 @@ def _parse_metadata_xml(xml, entity_id):
entity_desc = xml
else:
if xml.tag != etree.QName(SAML_XML_NS, 'EntitiesDescriptor'):
- raise MetadataParseError("Expected root element to be , not {}".format(xml.tag))
+ raise MetadataParseError(Text(u"Expected root element to be , not {}").format(xml.tag))
entity_desc = xml.find(
".//{}[@entityID='{}']".format(etree.QName(SAML_XML_NS, 'EntityDescriptor'), entity_id)
)
if not entity_desc:
- raise MetadataParseError("Can't find EntityDescriptor for entityID {}".format(entity_id))
+ raise MetadataParseError(u"Can't find EntityDescriptor for entityID {}".format(entity_id))
expires_at = None
if "validUntil" in xml.attrib:
diff --git a/common/djangoapps/third_party_auth/tests/specs/base.py b/common/djangoapps/third_party_auth/tests/specs/base.py
index 190e8edfe5..05aa6e1894 100644
--- a/common/djangoapps/third_party_auth/tests/specs/base.py
+++ b/common/djangoapps/third_party_auth/tests/specs/base.py
@@ -63,7 +63,10 @@ class HelperMixin(object):
"""
self.assertEqual(200, response.status_code)
# Check that the correct provider was selected.
- self.assertIn('successfully signed in with %s' % self.provider.name, response.content)
+ self.assertIn(
+ u'successfully signed in with %s' % self.provider.name,
+ response.content.decode(response.charset)
+ )
# Expect that each truthy value we've prepopulated the register form
# with is actually present.
form_field_data = self.provider.get_register_form_data(pipeline_kwargs)
@@ -120,8 +123,8 @@ class HelperMixin(object):
"""Asserts failure on /login for missing social auth looks right."""
self.assertEqual(403, response.status_code)
self.assertIn(
- "successfully logged into your %s account, but this account isn't linked" % self.provider.name,
- response.content
+ u"successfully logged into your %s account, but this account isn't linked" % self.provider.name,
+ response.content.decode(response.charset)
)
def assert_json_failure_response_is_username_collision(self, response):
diff --git a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py
index e195e3efd2..ec6ba70da7 100644
--- a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py
+++ b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py
@@ -290,13 +290,13 @@ class TestShibIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin
self.assertEqual(mock_log.call_count, 4)
(msg, action_type, idp_name, xml), _kwargs = mock_log.call_args_list[0]
- self.assertTrue(msg.startswith("SAML login %s"))
+ self.assertTrue(msg.startswith(u"SAML login %s"))
self.assertEqual(action_type, "request")
self.assertEqual(idp_name, self.PROVIDER_IDP_SLUG)
self.assertIn('\S+)', r'(?P[^\)]+)', r'(?P\S+)', r'(?P\d+)'))
user_matches = re.match(user_pattern, response.text)
if user_matches:
@@ -95,5 +95,5 @@ class ConfigModelFixture(object):
return session
else:
- msg = "Could not log in to use ConfigModel restful API. Status code: {0}".format(response.status_code)
+ msg = u"Could not log in to use ConfigModel restful API. Status code: {0}".format(response.status_code)
raise ConfigModelFixtureError(msg)
diff --git a/common/test/acceptance/fixtures/course.py b/common/test/acceptance/fixtures/course.py
index 4d16d5bbf6..f9ac1c9c1c 100644
--- a/common/test/acceptance/fixtures/course.py
+++ b/common/test/acceptance/fixtures/course.py
@@ -74,7 +74,7 @@ class XBlockFixtureDesc(object):
Return a string representation of the description.
Useful for error messages.
"""
- return dedent("""
+ return dedent(u"""
".format(**self._course_dict)
+ return u"".format(**self._course_dict)
def add_course_details(self, course_details):
"""
@@ -234,14 +234,14 @@ class CourseFixture(XBlockContainerFixture):
if not response.ok:
raise FixtureError(
- "Could not retrieve course outline json. Status was {0}".format(
+ u"Could not retrieve course outline json. Status was {0}".format(
response.status_code))
try:
course_outline_json = response.json()
except ValueError:
raise FixtureError(
- "Could not decode course outline as JSON: '{0}'".format(response)
+ u"Could not decode course outline as JSON: '{0}'".format(response)
)
return course_outline_json
@@ -289,18 +289,18 @@ class CourseFixture(XBlockContainerFixture):
except ValueError:
raise FixtureError(
- "Could not parse response from course request as JSON: '{0}'".format(
+ u"Could not parse response from course request as JSON: '{0}'".format(
response.content))
# This will occur if the course identifier is not unique
if err is not None:
- raise FixtureError("Could not create course {0}. Error message: '{1}'".format(self, err))
+ raise FixtureError(u"Could not create course {0}. Error message: '{1}'".format(self, err))
if response.ok:
self._course_key = response.json()['course_key']
else:
raise FixtureError(
- "Could not create course {0}. Status was {1}\nResponse content was: {2}".format(
+ u"Could not create course {0}. Status was {1}\nResponse content was: {2}".format(
self._course_dict, response.status_code, response.content))
def _configure_course(self):
@@ -314,14 +314,14 @@ class CourseFixture(XBlockContainerFixture):
if not response.ok:
raise FixtureError(
- "Could not retrieve course details. Status was {0}".format(
+ u"Could not retrieve course details. Status was {0}".format(
response.status_code))
try:
details = response.json()
except ValueError:
raise FixtureError(
- "Could not decode course details as JSON: '{0}'".format(details)
+ u"Could not decode course details as JSON: '{0}'".format(details)
)
# Update the old details with our overrides
@@ -335,7 +335,7 @@ class CourseFixture(XBlockContainerFixture):
if not response.ok:
raise FixtureError(
- "Could not update course details to '{0}' with {1}: Status was {2}.".format(
+ u"Could not update course details to '{0}' with {1}: Status was {2}.".format(
self._course_details, url, response.status_code))
def _install_course_handouts(self):
@@ -346,10 +346,10 @@ class CourseFixture(XBlockContainerFixture):
# Construct HTML with each of the handout links
handouts_li = [
- '
'.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")
diff --git a/common/test/acceptance/tests/discussion/test_discussion_management.py b/common/test/acceptance/tests/discussion/test_discussion_management.py
index c9abd58049..a1af93790f 100644
--- a/common/test/acceptance/tests/discussion/test_discussion_management.py
+++ b/common/test/acceptance/tests/discussion/test_discussion_management.py
@@ -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.
diff --git a/common/test/acceptance/tests/helpers.py b/common/test/acceptance/tests/helpers.py
index 4d323d5824..e95b4521b5 100644
--- a/common/test/acceptance/tests/helpers.py
+++ b/common/test/acceptance/tests/helpers.py
@@ -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
diff --git a/common/test/acceptance/tests/lms/test_library.py b/common/test/acceptance/tests/lms/test_library.py
index 972dbe427c..8ceb16b117 100644
--- a/common/test/acceptance/tests/lms/test_library.py
+++ b/common/test/acceptance/tests/lms/test_library.py
@@ -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([
- "{item}".format(correct=correct, item=item)
+ u"{item}".format(correct=correct, item=item)
for item, correct in items
])
- return textwrap.dedent("""
+ return textwrap.dedent(u"""
{name}
@@ -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"""
{name}
diff --git a/common/test/acceptance/tests/lms/test_lms.py b/common/test/acceptance/tests/lms/test_lms.py
index 34d089b72f..84656efecb 100644
--- a/common/test/acceptance/tests/lms/test_lms.py
+++ b/common/test/acceptance/tests/lms/test_lms.py
@@ -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)
diff --git a/common/test/acceptance/tests/lms/test_lms_courseware.py b/common/test/acceptance/tests/lms/test_lms_courseware.py
index 9cac09a192..2fc8aa0e8b 100644
--- a/common/test/acceptance/tests/lms/test_lms_courseware.py
+++ b/common/test/acceptance/tests/lms/test_lms_courseware.py
@@ -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
diff --git a/common/test/acceptance/tests/lms/test_lms_dashboard.py b/common/test/acceptance/tests/lms/test_lms_dashboard.py
index a4c5c970ab..58cecf49a9 100644
--- a/common/test/acceptance/tests/lms/test_lms_dashboard.py
+++ b/common/test/acceptance/tests/lms/test_lms_dashboard.py
@@ -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()
diff --git a/common/test/acceptance/tests/lms/test_lms_edxnotes.py b/common/test/acceptance/tests/lms/test_lms_edxnotes.py
index a296ad8145..8a92a91145 100644
--- a/common/test/acceptance/tests/lms/test_lms_edxnotes.py
+++ b/common/test/acceptance/tests/lms/test_lms_edxnotes.py
@@ -59,14 +59,14 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 2",
- data="""
Annotate this!
""".format(self.selector)
+ data=u"""
Annotate this!
""".format(self.selector)
),
),
XBlockFixtureDesc("vertical", "Test Unit 2").add_children(
XBlockFixtureDesc(
"html",
"Test HTML 3",
- data="""
Annotate this!
""".format(self.selector)
+ data=u"""
Annotate this!
""".format(self.selector)
),
),
),
@@ -75,7 +75,7 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 4",
- data="""
+ data=u"""
Annotate this!
""".format(self.selector)
),
@@ -88,14 +88,14 @@ class EdxNotesTestMixin(UniqueCourseTest):
XBlockFixtureDesc(
"html",
"Test HTML 5",
- data="""
+ data=u"""
Annotate this!
""".format(self.selector)
),
XBlockFixtureDesc(
"html",
"Test HTML 6",
- data="""
Annotate this!
""".format(self.selector)
+ data=u"""
Annotate this!
""".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):
diff --git a/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py b/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py
index 1e8495a45f..6a22d918e9 100644
--- a/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py
+++ b/common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py
@@ -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
)
diff --git a/common/test/acceptance/tests/lms/test_lms_matlab_problem.py b/common/test/acceptance/tests/lms/test_lms_matlab_problem.py
index 9206a0f108..dcb3ccdb4e 100644
--- a/common/test/acceptance/tests/lms/test_lms_matlab_problem.py
+++ b/common/test/acceptance/tests/lms/test_lms_matlab_problem.py
@@ -21,7 +21,7 @@ class MatlabProblemTest(ProblemsTest):
"""
Create a matlab problem for the test.
"""
- problem_data = dedent("""
+ problem_data = dedent(u"""
diff --git a/common/test/acceptance/tests/lms/test_lms_problems.py b/common/test/acceptance/tests/lms/test_lms_problems.py
index 659df27859..907b69ecdf 100644
--- a/common/test/acceptance/tests/lms/test_lms_problems.py
+++ b/common/test/acceptance/tests/lms/test_lms_problems.py
@@ -76,7 +76,7 @@ class ProblemClarificationTest(ProblemsTest):
"""
Create a problem with a
"""
- xml = dedent("""
+ xml = dedent(u"""
@@ -705,7 +705,7 @@ class ProblemQuestionDescriptionTest(ProblemsTest):
"""
Create a problem with question and description.
"""
- xml = dedent("""
+ xml = dedent(u"""
diff --git a/common/test/acceptance/tests/lms/test_problem_types.py b/common/test/acceptance/tests/lms/test_problem_types.py
index 9484195e55..c7187b4380 100644
--- a/common/test/acceptance/tests/lms/test_problem_types.py
+++ b/common/test/acceptance/tests/lms/test_problem_types.py
@@ -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):
diff --git a/common/test/acceptance/tests/lms/test_progress_page.py b/common/test/acceptance/tests/lms/test_progress_page.py
index c5494e2b7b..b8133e9bbf 100644
--- a/common/test/acceptance/tests/lms/test_progress_page.py
+++ b/common/test/acceptance/tests/lms/test_progress_page.py
@@ -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):
diff --git a/common/test/acceptance/tests/lms/test_teams.py b/common/test/acceptance/tests/lms/test_teams.py
index 233777b820..43c422610f 100644
--- a/common/test/acceptance/tests/lms/test_teams.py
+++ b/common/test/acceptance/tests/lms/test_teams.py
@@ -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']
)
diff --git a/common/test/acceptance/tests/studio/base_studio_test.py b/common/test/acceptance/tests/studio/base_studio_test.py
index d882233253..70a0d45f1a 100644
--- a/common/test/acceptance/tests/studio/base_studio_test.py
+++ b/common/test/acceptance/tests/studio/base_studio_test.py
@@ -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()
diff --git a/common/test/acceptance/tests/studio/test_studio_container.py b/common/test/acceptance/tests/studio/test_studio_container.py
index e8ba36a73c..988cc6ae51 100644
--- a/common/test/acceptance/tests/studio/test_studio_container.py
+++ b/common/test/acceptance/tests/studio/test_studio_container.py
@@ -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):
"""
diff --git a/common/test/acceptance/tests/studio/test_studio_grading.py b/common/test/acceptance/tests/studio/test_studio_grading.py
index e84c787374..798b9667e4 100644
--- a/common/test/acceptance/tests/studio/test_studio_grading.py
+++ b/common/test/acceptance/tests/studio/test_studio_grading.py
@@ -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):
diff --git a/common/test/acceptance/tests/studio/test_studio_html_editor.py b/common/test/acceptance/tests/studio/test_studio_html_editor.py
index 7756324d36..54288cc1e6 100644
--- a/common/test/acceptance/tests/studio/test_studio_html_editor.py
+++ b/common/test/acceptance/tests/studio/test_studio_html_editor.py
@@ -150,7 +150,7 @@ class HTMLComponentEditorTests(ContainerBase):
-->
""
"""
- content = '
pages
'
+ content = u'
pages
'
# Add HTML Text type component
self._add_component('Text')
diff --git a/common/test/acceptance/tests/studio/test_studio_library_container.py b/common/test/acceptance/tests/studio/test_studio_library_container.py
index 3ad265efd7..cdf678669c 100644
--- a/common/test/acceptance/tests/studio/test_studio_library_container.py
+++ b/common/test/acceptance/tests/studio/test_studio_library_container.py
@@ -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])
diff --git a/common/test/acceptance/tests/studio/test_studio_settings_certificates.py b/common/test/acceptance/tests/studio/test_studio_settings_certificates.py
index 92366e0b73..76a2eab7ce 100644
--- a/common/test/acceptance/tests/studio/test_studio_settings_certificates.py
+++ b/common/test/acceptance/tests/studio/test_studio_settings_certificates.py
@@ -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):
diff --git a/common/test/acceptance/tests/studio/test_studio_tabs.py b/common/test/acceptance/tests/studio/test_studio_tabs.py
index 6dc537ce94..79b261810c 100644
--- a/common/test/acceptance/tests/studio/test_studio_tabs.py
+++ b/common/test/acceptance/tests/studio/test_studio_tabs.py
@@ -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):
diff --git a/common/test/acceptance/tests/test_annotatable.py b/common/test/acceptance/tests/test_annotatable.py
index 0dbe587145..ce8d54d153 100644
--- a/common/test/acceptance/tests/test_annotatable.py
+++ b/common/test/acceptance/tests/test_annotatable.py
@@ -28,14 +28,14 @@ class AnnotatableProblemTest(UniqueCourseTest):
USERNAME = "STAFF_TESTER"
EMAIL = "johndoe@example.com"
- DATA_TEMPLATE = dedent("""\
+ DATA_TEMPLATE = dedent(u"""\
Instruction text
{}
""")
- ANNOTATION_TEMPLATE = dedent("""\
+ ANNOTATION_TEMPLATE = dedent(u"""\
Before {0}.
Region Contents {0}
@@ -43,7 +43,7 @@ class AnnotatableProblemTest(UniqueCourseTest):
After {0}.
""")
- PROBLEM_TEMPLATE = dedent("""\
+ PROBLEM_TEMPLATE = dedent(u"""\
@@ -63,7 +63,7 @@ class AnnotatableProblemTest(UniqueCourseTest):
""")
- OPTION_TEMPLATE = """"""
+ OPTION_TEMPLATE = u""""""
def setUp(self):
super(AnnotatableProblemTest, self).setUp()
diff --git a/common/test/acceptance/tests/video/test_video_events.py b/common/test/acceptance/tests/video/test_video_events.py
index 88199b8d97..b1a8d5bf97 100644
--- a/common/test/acceptance/tests/video/test_video_events.py
+++ b/common/test/acceptance/tests/video/test_video_events.py
@@ -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
diff --git a/common/test/acceptance/tests/video/test_video_module.py b/common/test/acceptance/tests/video/test_video_module.py
index 277f2acaa2..33c96e69bc 100644
--- a/common/test/acceptance/tests/video/test_video_module.py
+++ b/common/test/acceptance/tests/video/test_video_module.py
@@ -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))
diff --git a/common/test/utils.py b/common/test/utils.py
index d4012d8006..6262f4180a 100644
--- a/common/test/utils.py
+++ b/common/test/utils.py
@@ -133,7 +133,7 @@ class reprwrapper(object):
"""
def __init__(self, func):
self._func = func
- self.repr = 'Func: {}'.format(func.__name__)
+ self.repr = u'Func: {}'.format(func.__name__)
functools.update_wrapper(self, func)
def __call__(self, *args, **kw):