diff --git a/openedx/features/learner_profile/tests/views/test_learner_profile.py b/openedx/features/learner_profile/tests/views/test_learner_profile.py
index 5dd04009f5..eb58c3cedd 100644
--- a/openedx/features/learner_profile/tests/views/test_learner_profile.py
+++ b/openedx/features/learner_profile/tests/views/test_learner_profile.py
@@ -1,11 +1,10 @@
-# -*- coding: utf-8 -*-
""" Tests for student profile views. """
import datetime
import ddt
-import mock
+from unittest import mock
from django.conf import settings
from django.test import override_settings # lint-amnesty, pylint: disable=unused-import
from django.test.client import RequestFactory
@@ -49,7 +48,7 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
]
def setUp(self):
- super(LearnerProfileViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
+ super().setUp()
self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD)
self.other_user = UserFactory.create(username=self.OTHER_USERNAME, password=self.PASSWORD)
self.client.login(username=self.USERNAME, password=self.PASSWORD)
@@ -125,7 +124,7 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
def test_records_link(self):
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
response = self.client.get(path=profile_path)
- self.assertContains(response, u''.format(CREDENTIALS_PUBLIC_SERVICE_URL))
+ self.assertContains(response, f'')
def test_undefined_profile_page(self):
"""
@@ -155,9 +154,9 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
cert = self._create_certificate(enrollment_mode=cert_mode)
cert.save()
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
- self.assertContains(response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=cert_mode))
+ self.assertContains(response, f'card certificate-card mode-{cert_mode}')
@ddt.data(
['downloadable', True],
@@ -175,12 +174,12 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
# Ensure that this test is actually using both passing and non-passing certs.
assert is_passing_status(cert.status) == is_passed_status
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
if is_passed_status:
- self.assertContains(response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=cert.mode))
+ self.assertContains(response, f'card certificate-card mode-{cert.mode}')
else:
- self.assertNotContains(response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=cert.mode))
+ self.assertNotContains(response, f'card certificate-card mode-{cert.mode}')
def test_certificate_for_missing_course(self):
"""
@@ -190,9 +189,9 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
cert = self._create_certificate(course_key=CourseLocator.from_string('course-v1:edX+INVALID+1'))
cert.save()
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
- self.assertNotContains(response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=cert.mode))
+ self.assertNotContains(response, f'card certificate-card mode-{cert.mode}')
@ddt.data(True, False)
def test_no_certificate_visibility(self, own_profile):
@@ -202,7 +201,7 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
another user that does not have any certificates.
"""
profile_username = self.user.username if own_profile else self.other_user.username
- response = self.client.get('/u/{username}'.format(username=profile_username))
+ response = self.client.get(f'/u/{profile_username}')
if own_profile:
self.assertContains(response, 'You haven't earned any certificates yet.')
@@ -212,7 +211,7 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
@ddt.data(True, False)
def test_explore_courses_visibility(self, courses_browsable):
with mock.patch.dict('django.conf.settings.FEATURES', {'COURSES_ARE_BROWSABLE': courses_browsable}):
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
if courses_browsable:
self.assertContains(response, 'Explore New Courses')
else:
@@ -230,9 +229,9 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
cert = self._create_certificate(course_key=course.id)
cert.save()
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
- self.assertNotContains(response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=cert.mode))
+ self.assertNotContains(response, f'card certificate-card mode-{cert.mode}')
def test_certificates_visible_only_for_staff_and_profile_user(self):
"""
@@ -266,16 +265,16 @@ class LearnerProfileViewTest(SiteMixin, UrlResetMixin, ModuleStoreTestCase):
cert.download_url = ''
cert.save()
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
self.assertNotContains(
- response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=CourseMode.VERIFIED)
+ response, f'card certificate-card mode-{CourseMode.VERIFIED}'
)
course_overview = CourseOverview.get_from_id(self.course.id)
course_overview.has_any_active_web_certificate = True
course_overview.save()
- response = self.client.get('/u/{username}'.format(username=self.user.username))
+ response = self.client.get(f'/u/{self.user.username}')
self.assertContains(
- response, u'card certificate-card mode-{cert_mode}'.format(cert_mode=CourseMode.VERIFIED)
+ response, f'card certificate-card mode-{CourseMode.VERIFIED}'
)
diff --git a/openedx/features/learner_profile/views/learner_profile.py b/openedx/features/learner_profile/views/learner_profile.py
index 23d18fdf9d..99fa9259f0 100644
--- a/openedx/features/learner_profile/views/learner_profile.py
+++ b/openedx/features/learner_profile/views/learner_profile.py
@@ -46,7 +46,7 @@ def learner_profile(request, username):
GET /account/profile
"""
if should_redirect_to_profile_microfrontend():
- profile_microfrontend_url = "{}{}".format(settings.PROFILE_MICROFRONTEND_URL, username)
+ profile_microfrontend_url = f"{settings.PROFILE_MICROFRONTEND_URL}{username}"
return redirect(profile_microfrontend_url)
try:
diff --git a/openedx/features/lti_course_tab/tab.py b/openedx/features/lti_course_tab/tab.py
index 8d1dc17552..a6c90e4023 100644
--- a/openedx/features/lti_course_tab/tab.py
+++ b/openedx/features/lti_course_tab/tab.py
@@ -176,7 +176,7 @@ class LtiCourseTab(LtiCourseLaunchMixin, EnrolledTab):
tab_dict['name'] = name
tab_dict['link_func'] = link_func
- tab_dict['tab_id'] = 'lti_tab_{0}'.format(self.lti_config_id)
+ tab_dict['tab_id'] = f'lti_tab_{self.lti_config_id}'
super().__init__(tab_dict)
diff --git a/openedx/features/personalized_learner_schedules/call_to_action.py b/openedx/features/personalized_learner_schedules/call_to_action.py
index 2bdf096776..d078bfb396 100644
--- a/openedx/features/personalized_learner_schedules/call_to_action.py
+++ b/openedx/features/personalized_learner_schedules/call_to_action.py
@@ -153,7 +153,7 @@ class PersonalizedLearnerScheduleCallToAction:
},
'research_event_data': {
'block_id': str(xblock.location),
- 'location': '{category}-view'.format(category=xblock.category),
+ 'location': f'{xblock.category}-view',
},
}