Fix 29 anomalous-backslash-in-string errors
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1614,7 +1614,7 @@ class AnnotationInput(InputTypeBase):
|
||||
|
||||
@registry.register
|
||||
class ChoiceTextGroup(InputTypeBase):
|
||||
"""
|
||||
r"""
|
||||
Groups of radiobutton/checkboxes with text inputs.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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 = "####"
|
||||
|
||||
|
||||
@@ -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 = "####"
|
||||
|
||||
|
||||
@@ -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('(?P<url>https?://[^\s]+)', email_body)
|
||||
result = re.search(r'(?P<url>https?://[^\s]+)', email_body)
|
||||
self.assertIsNot(result, None)
|
||||
activation_link = result.group('url')
|
||||
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user