diff options
author | kumar <kumar.mcmillan@gmail.com> | 2011-03-22 10:01:14 -0500 |
---|---|---|
committer | kumar <kumar.mcmillan@gmail.com> | 2011-03-22 10:01:14 -0500 |
commit | 4d6c8b282500b3b3d0f9c0e8720eb676040d6ba9 (patch) | |
tree | 0259d5487c572ef60e7ff0490627d038d353fee9 /unit_tests | |
parent | 056d87c4b64d03a8e1107e43e97ea1c73b630c24 (diff) | |
download | nose-4d6c8b282500b3b3d0f9c0e8720eb676040d6ba9.tar.gz |
Fixes mishandling of custom exceptions during failures (Issue 405)
Diffstat (limited to 'unit_tests')
-rw-r--r-- | unit_tests/test_result_proxy.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/unit_tests/test_result_proxy.py b/unit_tests/test_result_proxy.py index 9ed1e11..3d6e2ac 100644 --- a/unit_tests/test_result_proxy.py +++ b/unit_tests/test_result_proxy.py @@ -159,6 +159,30 @@ class TestResultProxy(unittest.TestCase): case(proxy) assert proxy.shouldStop assert res.shouldStop - + + def test_coercion_of_custom_exception(self): + from nose.case import Test + + class CustomException(Exception): + def __init__(self, message, two, three): + Exception.__init__(self, message) + + class TC(unittest.TestCase): + def runTest(self): + pass + + test = TC() + case = Test(test) + res = unittest.TestResult() + try: + raise CustomException("the error", 2, 3) + except: + etype, val, tb = sys.exc_info() + val = str(val) # simulate plugin shenanigans + proxy = ResultProxy(res, test=case) + # Python 3 coercion should happen here without error + proxy.addError(test, (etype, val, tb)) + proxy.addFailure(test, (etype, val, tb)) + if __name__ == '__main__': unittest.main() |