~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert Collins
  • Date: 2007-03-22 10:07:44 UTC
  • mto: (2378.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2379.
  • Revision ID: robertc@robertcollins.net-20070322100744-96m81fcue8hgsfnd
Add support for calling addNotSupported on TestResults to bzr TestCase's
when _test_needs_features contains unavailable features. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1020
1020
        """This test has failed for some known reason."""
1021
1021
        raise KnownFailure(reason)
1022
1022
 
 
1023
    def run(self, result=None):
 
1024
        if result is None: result = self.defaultTestResult()
 
1025
        for feature in getattr(self, '_test_needs_features', []):
 
1026
            if not feature.available():
 
1027
                result.startTest(self)
 
1028
                if getattr(result, 'addNotSupported', None):
 
1029
                    result.addNotSupported(self, feature)
 
1030
                else:
 
1031
                    result.addSuccess(self)
 
1032
                result.stopTest(self)
 
1033
                return
 
1034
        return unittest.TestCase.run(self, result)
 
1035
 
1023
1036
    def tearDown(self):
1024
1037
        self._runCleanups()
1025
1038
        unittest.TestCase.tearDown(self)