~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

(gz) Update knownFailure so the reason isn't lost on Python 2.7 (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1793
1793
        self._preserved_lazy_hooks.clear()
1794
1794
 
1795
1795
    def knownFailure(self, reason):
1796
 
        """This test has failed for some known reason."""
1797
 
        raise KnownFailure(reason)
 
1796
        """Declare that this test fails for a known reason
 
1797
 
 
1798
        Tests that are known to fail should generally be using expectedFailure
 
1799
        with an appropriate reverse assertion if a change could cause the test
 
1800
        to start passing. Conversely if the test has no immediate prospect of
 
1801
        succeeding then using skip is more suitable.
 
1802
 
 
1803
        When this method is called while an exception is being handled, that
 
1804
        traceback will be used, otherwise a new exception will be thrown to
 
1805
        provide one but won't be reported.
 
1806
        """
 
1807
        self._add_reason(reason)
 
1808
        try:
 
1809
            exc_info = sys.exc_info()
 
1810
            if exc_info != (None, None, None):
 
1811
                self._report_traceback(exc_info)
 
1812
            else:
 
1813
                try:
 
1814
                    raise self.failureException(reason)
 
1815
                except self.failureException:
 
1816
                    exc_info = sys.exc_info()
 
1817
            # GZ 02-08-2011: Maybe cleanup this err.exc_info attribute too?
 
1818
            raise testtools.testcase._ExpectedFailure(exc_info)
 
1819
        finally:
 
1820
            del exc_info
1798
1821
 
1799
1822
    def _suppress_log(self):
1800
1823
        """Remove the log info from details."""