def test_search_wrong_type(self): uut = SearcherCollection([ RegexSearcher(b'omicron'), RegexSearcher(b'[eu]psilon'), ]) with self.assertRaises(TypeError): uut.search(u('pi omicron mu'))
def test_multi_regex_single_match(self): uut = SearcherCollection([ RegexSearcher('omicron'), RegexSearcher('[eu]psilon'), ]) match = uut.search('pi epsilon iota rho') self.assertIsNotNone(match) self.assertEqual(1, uut.index(match.searcher)) self.assertEqual(3, match.start) self.assertEqual(10, match.end)
def test_multi_regex_multi_match(self): uut = SearcherCollection([ RegexSearcher(u('omicron')), RegexSearcher(u('[eu]psilon')), TextSearcher(u('pi')), TextSearcher(u('iota')), ]) match = uut.search(u('pi iota epsilon upsilon omicron')) self.assertIsNotNone(match) self.assertEqual(2, uut.index(match.searcher)) self.assertEqual(0, match.start) self.assertEqual(2, match.end)