Example #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)
Example #2
0
 def test_bad_replace_word(self):
     with self.assertRaises(TypeError):
         replace.replace_strings("", "", [""])
Example #3
0
 def test_bad_original_str(self):
     with self.assertRaises(TypeError):
         replace.replace_strings([""], "", "")
Example #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)
Example #5
0
 def test_replace_delimiter(self):
     result = replace.replace_strings(delimiter_string, RD, "2")
     self.assertEqual("hi2 fun2 times2", result)
Example #6
0
 def test_replace_single_and_double_quote(self):
     result = replace.replace_strings(normal_string, ["'", '"'], "54")
     self.assertEqual("The 54quick54 54brown54 fox.", result)
Example #7
0
 def test_replace_double_quote(self):
     result = replace.replace_strings(normal_string, '"', "")
     self.assertEqual("The 'quick' brown fox.", result)
Example #8
0
 def test_replace_single_quote(self):
     result = replace.replace_strings(normal_string, "'", "1")
     self.assertEqual('The 1quick1 "brown" fox.', result)