diff --git a/cms/djangoapps/contentstore/features/textbooks.py b/cms/djangoapps/contentstore/features/textbooks.py index cd756b2242..9b46dabc51 100644 --- a/cms/djangoapps/contentstore/features/textbooks.py +++ b/cms/djangoapps/contentstore/features/textbooks.py @@ -89,7 +89,7 @@ def check_textbook(_step, textbook_name, chapter_name): assert_equal(chapter, chapter_name) -@step(u'I should see a textbook named "([^"]*)" with (\d+) chapters') +@step(r'I should see a textbook named "([^"]*)" with (\d+) chapters') def check_textbook_chapters(_step, textbook_name, num_chapters_str): num_chapters = int(num_chapters_str) title = world.css_text(".textbook .view-textbook h3.textbook-title", index=0) diff --git a/cms/djangoapps/contentstore/features/transcripts.py b/cms/djangoapps/contentstore/features/transcripts.py index e9e25958aa..87f41b3a9f 100644 --- a/cms/djangoapps/contentstore/features/transcripts.py +++ b/cms/djangoapps/contentstore/features/transcripts.py @@ -134,7 +134,7 @@ def i_see_button(_step, not_see, button_type): assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0], TRANSCRIPTS_BUTTONS[button][1]) -@step('I (.*)see (.*)button "([^"]*)" number (\d+)$') +@step(r'I (.*)see (.*)button "([^"]*)" number (\d+)$') def i_see_button_with_custom_text(_step, not_see, button_type, custom_text, index): button = button_type.strip() custom_text = custom_text.strip() @@ -153,7 +153,7 @@ def click_button_transcripts_variant(_step, button_type): world.wait_for_ajax_complete() -@step('I click transcript button "([^"]*)" number (\d+)$') +@step(r'I click transcript button "([^"]*)" number (\d+)$') def click_button_index(_step, button_type, index): button = button_type.strip() index = int(index.strip()) - 1 @@ -178,7 +178,7 @@ def remove_transcripts_from_store(_step, subs_id): print 'Transcript file was NOT found and not removed.' -@step('I enter a "([^"]+)" source to field number (\d+)$') +@step(r'I enter a "([^"]+)" source to field number (\d+)$') def i_enter_a_source(_step, link, index): index = int(index) - 1 diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 238b111a22..f5d079ac64 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -1614,7 +1614,7 @@ class AnnotationInput(InputTypeBase): @registry.register class ChoiceTextGroup(InputTypeBase): - """ + r""" Groups of radiobutton/checkboxes with text inputs. Examples: diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 1a1c0179e9..921148b1f7 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1942,7 +1942,7 @@ class NumericalResponse(LoncapaResponse): @registry.register class StringResponse(LoncapaResponse): - """ + r""" This response type allows one or more answers. Additional answers are added by `additional_answer` tag. diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index 35b61f003e..e3f486ccbf 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -658,7 +658,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring "Martin Luther King" ] - problem = self.build_problem(answer="\w*\.?.*Luther King\s*.*", case_sensitive=True, regexp=True) + problem = self.build_problem(answer=r"\w*\.?.*Luther King\s*.*", case_sensitive=True, regexp=True) for answer in answers: self.assert_grade(problem, answer, "correct") @@ -699,7 +699,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring self.assert_grade(problem, u"o", "incorrect") def test_backslash_and_unicode_regexps(self): - """ + r""" Test some special cases of [unicode] regexps. One needs to use either r'' strings or write real `repr` of unicode strings, because of the following @@ -715,14 +715,14 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring So a\d in front-end editor will become a\\\\d in xml, so it will match a1 as student answer. """ problem = self.build_problem(answer=ur"5\\æ", case_sensitive=False, regexp=True) - self.assert_grade(problem, u"5\æ", "correct") + self.assert_grade(problem, ur"5\æ", "correct") problem = self.build_problem(answer=u"5\\\\æ", case_sensitive=False, regexp=True) - self.assert_grade(problem, u"5\æ", "correct") + self.assert_grade(problem, ur"5\æ", "correct") def test_backslash(self): problem = self.build_problem(answer=u"a\\\\c1", case_sensitive=False, regexp=True) - self.assert_grade(problem, u"a\c1", "correct") + self.assert_grade(problem, ur"a\c1", "correct") def test_special_chars(self): problem = self.build_problem(answer=ur"a \s1", case_sensitive=False, regexp=True) diff --git a/lms/djangoapps/courseware/features/lti.py b/lms/djangoapps/courseware/features/lti.py index fcefc44f64..4e5f958318 100644 --- a/lms/djangoapps/courseware/features/lti.py +++ b/lms/djangoapps/courseware/features/lti.py @@ -150,7 +150,7 @@ def set_incorrect_lti_passport(_step): i_am_registered_for_the_course(coursenum, metadata) -@step('the course has an LTI component with (.*) fields(?:\:)?$') # , new_page is(.*), graded is(.*) +@step(r'the course has an LTI component with (.*) fields(?:\:)?$') # , new_page is(.*), graded is(.*) def add_correct_lti_to_course(_step, fields): category = 'lti' metadata = { diff --git a/lms/djangoapps/instructor/features/data_download.py b/lms/djangoapps/instructor/features/data_download.py index 6701a52c06..1a628e8bde 100644 --- a/lms/djangoapps/instructor/features/data_download.py +++ b/lms/djangoapps/instructor/features/data_download.py @@ -74,7 +74,7 @@ def verify_report_is_generated(report_name_substring): world.wait_for_visible('#report-downloads-table') # Find table and assert a .csv file is present quoted_id = http.urlquote(world.course_key).replace('/', '_') - expected_file_regexp = quoted_id + '_' + report_name_substring + '_\d{4}-\d{2}-\d{2}-\d{4}\.csv' + expected_file_regexp = quoted_id + '_' + report_name_substring + r'_\d{4}-\d{2}-\d{2}-\d{4}\.csv' assert_regexp_matches( world.css_html('#report-downloads-table'), expected_file_regexp, msg="Expected report filename was not found." diff --git a/lms/djangoapps/shoppingcart/processors/CyberSource.py b/lms/djangoapps/shoppingcart/processors/CyberSource.py index 50bbabf7aa..b5e84453c1 100644 --- a/lms/djangoapps/shoppingcart/processors/CyberSource.py +++ b/lms/djangoapps/shoppingcart/processors/CyberSource.py @@ -219,9 +219,9 @@ def record_purchase(params, order): Record the purchase and run purchased_callbacks """ ccnum_str = params.get('card_accountNumber', '') - m = re.search("\d", ccnum_str) - if m: - ccnum = ccnum_str[m.start():] + first_digit = re.search(r"\d", ccnum_str) + if first_digit: + ccnum = ccnum_str[first_digit.start():] else: ccnum = "####" diff --git a/lms/djangoapps/shoppingcart/processors/CyberSource2.py b/lms/djangoapps/shoppingcart/processors/CyberSource2.py index 1410f31683..6720c17f71 100644 --- a/lms/djangoapps/shoppingcart/processors/CyberSource2.py +++ b/lms/djangoapps/shoppingcart/processors/CyberSource2.py @@ -404,9 +404,9 @@ def _record_purchase(params, order): # Parse the string to retrieve the digits. # If we can't find any digits, use placeholder values instead. ccnum_str = params.get('req_card_number', '') - mm = re.search("\d", ccnum_str) - if mm: - ccnum = ccnum_str[mm.start():] + first_digit = re.search(r"\d", ccnum_str) + if first_digit: + ccnum = ccnum_str[first_digit.start():] else: ccnum = "####" diff --git a/lms/djangoapps/student_account/test/test_views.py b/lms/djangoapps/student_account/test/test_views.py index ae710ef36d..0941ba8170 100644 --- a/lms/djangoapps/student_account/test/test_views.py +++ b/lms/djangoapps/student_account/test/test_views.py @@ -100,7 +100,7 @@ class StudentAccountUpdateTest(CacheIsolationTestCase, UrlResetMixin): # Retrieve the activation link from the email body email_body = mail.outbox[0].body - result = re.search('(?Phttps?://[^\s]+)', email_body) + result = re.search(r'(?Phttps?://[^\s]+)', email_body) self.assertIsNot(result, None) activation_link = result.group('url') diff --git a/lms/envs/cms/dev.py b/lms/envs/cms/dev.py index 275ff8fdeb..4e1f761ceb 100644 --- a/lms/envs/cms/dev.py +++ b/lms/envs/cms/dev.py @@ -38,9 +38,10 @@ DEBUG_TOOLBAR_PANELS += ( 'debug_toolbar_mongo.panel.MongoDebugPanel', ) -# HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS defines, as dictionary of regex's, a set of mappings of HTTP request hostnames to -# what the 'default' modulestore to use while processing the request -# for example 'preview.edx.org' should use the draft modulestore +# HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS defines, as dictionary of regex's, a +# set of mappings of HTTP request hostnames to what the 'default' modulestore +# to use while processing the request. +# for example 'preview.edx.org' should use the draft modulestore. HOSTNAME_MODULESTORE_DEFAULT_MAPPINGS = { - 'preview\.': 'draft-preferred' + r'preview\.': 'draft-preferred' }