test_hiermatch.py 782 B

123456789101112131415161718192021222324
  1. import unittest2
  2. from reportbug import hiermatch, exceptions
  3. test_strings_list = ['Beautiful is better than ugly.',
  4. 'Explicit is better than implicit.',
  5. 'Simple is better than complex.',
  6. 'Complex is better than complicated.',
  7. 'Flat is better than nested.',
  8. 'Sparse is better than dense.']
  9. class TestHiermatch(unittest2.TestCase):
  10. def test_egrep_list(self):
  11. res = hiermatch.egrep_list(None, '')
  12. self.assertIsNone(res)
  13. with self.assertRaises(exceptions.InvalidRegex):
  14. matches = hiermatch.egrep_list(test_strings_list, 42)
  15. matches = hiermatch.egrep_list(test_strings_list, 'better')
  16. self.assertEqual(len(matches), 6)