def __init__(self, string, parent=None): super().__init__(parent) self.fmt = QtGui.QTextCharFormat() self.fmt.setBackground(QtCore.Qt.GlobalColor.lightGray) self.reg = re.compile(wildcards_to_regex_pattern(string), re.IGNORECASE)
def test_special_chars(self): pattern = ']()\\^$|' regex = wildcards_to_regex_pattern(pattern) self.assertEqual(re.escape(pattern), regex) re.compile(regex)
def test_open_character_group(self): pattern = '[abc*?xyz[' regex = wildcards_to_regex_pattern(pattern) self.assertEqual('\\[abc.*.xyz\\[', regex) re.compile(regex)
def test_character_group_escape_square_brackets(self): pattern = '[a[b\\]c]' regex = wildcards_to_regex_pattern(pattern) self.assertEqual('[a[b\\]c]', regex) re.compile(regex)
def test_character_group(self): pattern = '[abc*?xyz]]' regex = wildcards_to_regex_pattern(pattern) self.assertEqual('[abc*?xyz]\\]', regex) re.compile(regex)
def test_escape(self): pattern = 'f\\?o\\*o?o*\\[o' regex = wildcards_to_regex_pattern(pattern) self.assertEqual('f\\?o\\*o.o.*\\[o', regex) re.compile(regex)
def test_wildcard_pattern(self): pattern = 'fo?o*' regex = wildcards_to_regex_pattern(pattern) self.assertEqual('fo.o.*', regex) re.compile(regex)