Fix 29 anomalous-backslash-in-string errors

This commit is contained in:
Ned Batchelder
2016-07-31 11:29:06 -04:00
parent ecffdacf5a
commit 76bc4fb98e
11 changed files with 25 additions and 24 deletions

View File

@@ -1614,7 +1614,7 @@ class AnnotationInput(InputTypeBase):
@registry.register
class ChoiceTextGroup(InputTypeBase):
"""
r"""
Groups of radiobutton/checkboxes with text inputs.
Examples:

View File

@@ -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.

View File

@@ -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)