[#60 state:fixed] Ignore invalid regexp in filter field

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40156
This commit is contained in:
hsoft 2009-09-29 11:15:36 +00:00
parent e5f3976b89
commit 01b06c90b2
2 changed files with 9 additions and 1 deletions

View File

@ -142,8 +142,11 @@ class Results(Markable):
else:
if not self.__filters:
self.__filters = []
try:
filter_re = re.compile(filter_str, re.IGNORECASE)
except re.error:
return # don't apply this filter.
self.__filters.append(filter_str)
filter_re = re.compile(filter_str, re.IGNORECASE)
if self.__filtered_dupes is None:
self.__filtered_dupes = flatten(g[:] for g in self.groups)
self.__filtered_dupes = set(dupe for dupe in self.__filtered_dupes if filter_re.search(dupe.name))

View File

@ -48,6 +48,11 @@ class TCResultsEmpty(TestCase):
def setUp(self):
self.results = Results(data)
def test_apply_invalid_filter(self):
# If the applied filter is an invalid regexp, just ignore the filter.
self.results.apply_filter('[') # invalid
self.test_stat_line() # make sure that the stats line isn't saying we applied a '[' filter
def test_stat_line(self):
self.assertEqual("0 / 0 (0.00 B / 0.00 B) duplicates marked.",self.results.stat_line)