def test_constructor_invalid(self):
        with self.assertRaises(ValueError):
            SearcherCollection([])
        with self.assertRaises(TypeError):
            SearcherCollection(1)
        with self.assertRaises(ValueError):
            SearcherCollection(TextSearcher(u('')), BytesSearcher(b''))

        NoSearchSearcher = type('NoSearchSearcher', (object,),
                                {'match_type': None})
        with self.assertRaises(TypeError):
            SearcherCollection(NoSearchSearcher())

        NoMatchTypeSearcher = type('NoMatchTypeSearcher', (object,),
                                   {'search': None})
        with self.assertRaises(TypeError):
            SearcherCollection(NoMatchTypeSearcher())
 def test_multi_match(self):
     uut = BytesSearcher(b'one')
     match = uut.search(b'one two three two one')
     self.assertIsNotNone(match)
     self.assertEqual(0, match.start)
     self.assertEqual(3, match.end)
 def test_repr(self):
     # Only check no exceptions thrown
     searcher = BytesSearcher(b'\x00\x00')
     repr(searcher)
 def test_single_match(self):
     uut = BytesSearcher(b'\x05\x05')
     match = uut.search(b'ascii with \x05\x05 bytes')
     self.assertIsNotNone(match)
     self.assertEqual(11, match.start)
     self.assertEqual(13, match.end)
 def test_no_match(self):
     uut = BytesSearcher(b'I will never match')
     self.assertEqual(None, uut.search(b'alpha beta gamma'))
 def test_not_patterns(self):
     with self.assertRaises(TypeError):
         BytesSearcher(None)
     with self.assertRaises(TypeError):
         BytesSearcher(5)
 def test_fail_using_text(self):
     with self.assertRaises(TypeError):
         BytesSearcher(u('I am Unicode text'))
 def test_binary_constructor(self):
     searcher = BytesSearcher(b'\x01\x02\x03\x04')
     self.assertEqual(searcher.match_type, six.binary_type)