コード例 #1
0
 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'))
コード例 #2
0
 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)
コード例 #3
0
 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)