~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testsweet.py

  • Committer: Robert Collins
  • Date: 2005-08-24 07:40:52 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050824074052-2e9ec0dd13958d20
make tests stop at the first failure, preventing multi-page omgs

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
InTempDir = FunctionalTestCase
265
265
 
266
266
 
 
267
class EarlyStoppingTestResultAdapter(object):
 
268
    """An adapter for TestResult to stop at the first first failure or error"""
 
269
 
 
270
    def __init__(self, result):
 
271
        self._result = result
 
272
 
 
273
    def addError(self, test, err):
 
274
        self._result.addError(test, err)
 
275
        self._result.stop()
 
276
 
 
277
    def addFailure(self, test, err):
 
278
        self._result.addFailure(test, err)
 
279
        self._result.stop()
 
280
 
 
281
    def __getattr__(self, name):
 
282
        return getattr(self._result, name)
 
283
 
 
284
    def __setattr__(self, name, value):
 
285
        if name == '_result':
 
286
            object.__setattr__(self, name, value)
 
287
        return setattr(self._result, name, value)
 
288
 
 
289
 
267
290
class _MyResult(unittest._TextTestResult):
268
291
    """
269
292
    Custom TestResult.
313
336
class TextTestRunner(unittest.TextTestRunner):
314
337
 
315
338
    def _makeResult(self):
316
 
        return _MyResult(self.stream, self.descriptions, self.verbosity)
 
339
        result = _MyResult(self.stream, self.descriptions, self.verbosity)
 
340
        return EarlyStoppingTestResultAdapter(result)
317
341
 
318
342
 
319
343
def run_suite(suite, name='test', verbose=False):