コード例 #1
0
 def test_replace_regex_chars(self):
     """
     Test replacing commonly used regex characters
     """
     result = replace.replace_strings(weird_string,
                                      ["^", "$", "*", ".", "?", "|", "]"],
                                      "2")
     self.assertEqual("22222222", result)
コード例 #2
0
 def test_bad_replace_word(self):
     with self.assertRaises(TypeError):
         replace.replace_strings("", "", [""])
コード例 #3
0
 def test_bad_original_str(self):
     with self.assertRaises(TypeError):
         replace.replace_strings([""], "", "")
コード例 #4
0
 def test_replace_nothing(self):
     """
     Test that the function returns an empty string if given empty strings
     """
     result = replace.replace_strings("", ["", ""], "", True)
     self.assertEqual("", result)
コード例 #5
0
 def test_replace_delimiter(self):
     result = replace.replace_strings(delimiter_string, RD, "2")
     self.assertEqual("hi2 fun2 times2", result)
コード例 #6
0
 def test_replace_single_and_double_quote(self):
     result = replace.replace_strings(normal_string, ["'", '"'], "54")
     self.assertEqual("The 54quick54 54brown54 fox.", result)
コード例 #7
0
 def test_replace_double_quote(self):
     result = replace.replace_strings(normal_string, '"', "")
     self.assertEqual("The 'quick' brown fox.", result)
コード例 #8
0
 def test_replace_single_quote(self):
     result = replace.replace_strings(normal_string, "'", "1")
     self.assertEqual('The 1quick1 "brown" fox.', result)