def on_finished(self, output, err=None): matches = None if output: try: matches = parser.parse_search_output(output) except Exception as e: err = e sublime.set_timeout( functools.partial(self._finish, output, matches, err=err))
def test_parse(self): output = textwrap.dedent("""\ a.txt:1:Too many cooks a.txt:2:TOO MANY cooks b.txt:34:How to cook """) expected = [ parser.FileResults('a.txt', [(1, 'Too many cooks'), (2, 'TOO MANY cooks')]), parser.FileResults('b.txt', [(34, 'How to cook')]) ] actual = parser.parse_search_output(output) self.assertEquals(expected, actual)
def test_parse_exception_with_bad_linenum(self): with self.assertRaises(parser._LexerException): parser.parse_search_output('a.txt:12bleh:Match')
def test_parse_exception(self): with self.assertRaises(parser._LexerException): parser.parse_search_output('I am a bad line.')
def test_parse_with_no_results(self): actual = parser.parse_search_output('') self.assertEquals([], actual)
def test_parse_single_line(self): expected = [parser.FileResults('a.txt', [(1, 'Too many cooks')])] actual = parser.parse_search_output('a.txt:1:Too many cooks') self.assertEquals(expected, actual)