diff -u nose-1.0.0/debian/changelog nose-1.0.0/debian/changelog --- nose-1.0.0/debian/changelog +++ nose-1.0.0/debian/changelog @@ -1,8 +1,16 @@ -nose (1.0.0-1~openstack~maverick1) maverick; urgency=low +nose (1.0.0-1ubuntu1~openstack~maverick1) maverick; urgency=low - * Built for maverick + * Backported for OpenStack for maverick - -- Monty Taylor Fri, 09 Sep 2011 09:10:54 -0700 + -- Monty Taylor Fri, 09 Sep 2011 10:01:42 -0700 + +nose (1.0.0-1ubuntu1) oneiric; urgency=low + + * nose/proxy.py, unit_tests/test_result_proxy.py: Fixes mishandling + of custom exceptions during failures. Changes based on upstream + commit:b3cdbd839e78 and will be part of 1.0.1 release. (LP: #814208) + + -- Dave Walker (Daviey) Thu, 21 Jul 2011 19:04:28 +0100 nose (1.0.0-1) unstable; urgency=low diff -u nose-1.0.0/debian/control nose-1.0.0/debian/control --- nose-1.0.0/debian/control +++ nose-1.0.0/debian/control @@ -1,7 +1,8 @@ Source: nose Section: python Priority: optional -Maintainer: Gustavo Noronha Silva +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Gustavo Noronha Silva Uploaders: Debian Python Modules Team , Torsten Marek Build-Depends: python (>= 2.5.4-1~), python-setuptools (>= 0.6a9), debhelper (>= 5.0.38), cdbs (>= 0.4.49), python-support (>= 0.8.1), python-sphinx (>= 0.6.1), libjs-jquery Homepage: http://somethingaboutorange.com/mrl/projects/nose/ only in patch2: unchanged: --- nose-1.0.0.orig/unit_tests/test_result_proxy.py +++ nose-1.0.0/unit_tests/test_result_proxy.py @@ -159,6 +159,30 @@ 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() only in patch2: unchanged: --- nose-1.0.0.orig/nose/proxy.py +++ nose-1.0.0/nose/proxy.py @@ -85,6 +85,19 @@ def __repr__(self): return repr(self.result) + def _prepareErr(self, err): + if not isinstance(err[1], Exception): + # Turn value back into an Exception (required in Python 3.x). + # Plugins do all sorts of crazy things with exception values. + try: + # The actual exception class is needed for failure detail + # but maybe other plugins? + value = err[0](err[1]) + except: + value = Exception(err[1]) + err = (err[0], value, err[2]) + return err + def assertMyTest(self, test): # The test I was called with must be my .test or my # .test's .test. or my .test.test's .case @@ -117,12 +130,9 @@ # test.passed is set in result, to account for error classes formatted = plugins.formatError(self.test, err) if formatted is not None: - if isinstance(formatted[1], basestring): - # Turn it back into an Exception (required in Python 3.x) - formatted = (formatted[0], Exception(formatted[1]), formatted[2]) err = formatted plugins.addError(self.test, err) - self.result.addError(self.test, err) + self.result.addError(self.test, self._prepareErr(err)) if not self.result.wasSuccessful() and self.config.stopOnError: self.shouldStop = True @@ -136,10 +146,8 @@ formatted = plugins.formatFailure(self.test, err) if formatted is not None: err = formatted - if not isinstance(err[1], Exception): - err = (err[0], err[0](err[1]), err[2]) plugins.addFailure(self.test, err) - self.result.addFailure(self.test, err) + self.result.addFailure(self.test, self._prepareErr(err)) if self.config.stopOnError: self.shouldStop = True @@ -178,4 +186,3 @@ """Tests that failed""") testsRun = proxied_attribute('result', 'testsRun', """Number of tests run""") -