test_utils.py 587 B

1234567891011121314151617181920212223
  1. from huey.tests.base import BaseTestCase
  2. from huey.utils import wrap_exception
  3. class MyException(Exception):
  4. pass
  5. class TestWrapException(BaseTestCase):
  6. def test_wrap_exception(self):
  7. def raise_keyerror():
  8. try:
  9. {}['huey']
  10. except KeyError as exc:
  11. raise wrap_exception(MyException)
  12. self.assertRaises(MyException, raise_keyerror)
  13. try:
  14. raise_keyerror()
  15. except MyException as exc:
  16. self.assertEqual(str(exc), "KeyError: 'huey'")
  17. else:
  18. assert False