def test_replace_regex_chars(self): """ Test replacing commonly used regex characters """ result = replace.replace_strings(weird_string, ["^", "$", "*", ".", "?", "|", "]"], "2") self.assertEqual("22222222", result)
def test_bad_replace_word(self): with self.assertRaises(TypeError): replace.replace_strings("", "", [""])
def test_bad_original_str(self): with self.assertRaises(TypeError): replace.replace_strings([""], "", "")
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)
def test_replace_delimiter(self): result = replace.replace_strings(delimiter_string, RD, "2") self.assertEqual("hi2 fun2 times2", result)
def test_replace_single_and_double_quote(self): result = replace.replace_strings(normal_string, ["'", '"'], "54") self.assertEqual("The 54quick54 54brown54 fox.", result)
def test_replace_double_quote(self): result = replace.replace_strings(normal_string, '"', "") self.assertEqual("The 'quick' brown fox.", result)
def test_replace_single_quote(self): result = replace.replace_strings(normal_string, "'", "1") self.assertEqual('The 1quick1 "brown" fox.', result)