/unit_tests/test_issue_101.py

https://bitbucket.org/jpellerin/nose/ · Python · 27 lines · 20 code · 7 blank · 0 comment · 2 complexity · 30a85941adbbf16c4bcc5e64edf454b4 MD5 · raw file

  1. import sys
  2. import unittest
  3. import warnings
  4. from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
  5. from nose.exc import SkipTest
  6. class TestErrorClassWithStringException(unittest.TestCase):
  7. def test_string_exception_not_masked(self):
  8. if sys.version_info >= (3,):
  9. raise SkipTest("Python 3.x does not support string exceptions")
  10. class X(Exception):
  11. pass
  12. class EP(ErrorClassPlugin):
  13. xes = ErrorClass(X, label='XXX', isfailure=True)
  14. warnings.filterwarnings(action='ignore', category=DeprecationWarning)
  15. try:
  16. raise "oh no!"
  17. except:
  18. exc = sys.exc_info()
  19. ep = EP()
  20. self.assertEqual(ep.addError(None, exc), None)