Skip to content

Commit

Permalink
Restore exception context when passed in loader's _makeFailedTest method
Browse files Browse the repository at this point in the history
Loader's `_makeFailedTest` now handles both the case where `exception` is an
Exception instance and the case where `exception` is an exception information
tuple (as given by `sys.exc_info()`). Rely on six.reraise to handle the latter
case.

Closes nose-devs#48.
  • Loading branch information
dlax committed May 28, 2015
1 parent bf99453 commit 19571d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nose2/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import traceback

import six

from nose2 import events
from nose2.compat import unittest

Expand Down Expand Up @@ -114,7 +116,11 @@ def discover(self, start_dir=None, pattern=None):

def _makeFailedTest(self, classname, methodname, exception):
def testFailure(self):
raise exception
if isinstance(exception, Exception):
raise exception
else:
# exception tuple (type, value, traceback)
six.reraise(*exception)
attrs = {methodname: testFailure}
TestClass = type(classname, (unittest.TestCase,), attrs)
return self.suiteClass((TestClass(methodname),))
Expand Down

0 comments on commit 19571d3

Please sign in to comment.