~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testsweet.py

  • Committer: Robert Collins
  • Date: 2005-08-23 08:24:32 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-20050823082432-fe403dbe973a8b7a
start unifying _MyResult and _TextTestResult

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
 
265
265
    No special behaviour for now.
266
266
    """
267
 
    def __init__(self, out, style):
268
 
        super(_MyResult, self).__init__(out, False, 0)
269
 
        self.out = out
 
267
    def __init__(self, stream, descriptions, verbosity, style):
 
268
        super(_MyResult, self).__init__(stream, descriptions, verbosity)
 
269
        self.out = stream
270
270
        assert style in ('none', 'progress', 'verbose')
271
271
        self.style = style
272
272
 
278
278
        if what == 'runit':
279
279
            what = test.shortDescription()
280
280
        if self.style == 'verbose':
281
 
            print >>self.out, '%-60.60s' % what,
282
 
            self.out.flush()
 
281
            print >>self.stream, '%-60.60s' % what,
 
282
            self.stream.flush()
283
283
 
284
284
    def addError(self, test, err):
285
285
        if self.style == 'verbose':
286
 
            print >>self.out, 'ERROR'
 
286
            print >>self.stream, 'ERROR'
287
287
        elif self.style == 'progress':
288
288
            self.stream.write('E')
289
289
        self.stream.flush()
291
291
 
292
292
    def addFailure(self, test, err):
293
293
        if self.style == 'verbose':
294
 
            print >>self.out, 'FAILURE'
 
294
            print >>self.stream, 'FAILURE'
295
295
        elif self.style == 'progress':
296
296
            self.stream.write('F')
297
297
        self.stream.flush()
299
299
 
300
300
    def addSuccess(self, test):
301
301
        if self.style == 'verbose':
302
 
            print >>self.out, 'OK'
 
302
            print >>self.stream, 'OK'
303
303
        elif self.style == 'progress':
304
304
            self.stream.write('~')
305
305
        self.stream.flush()
330
330
        self.style = style
331
331
 
332
332
    def _makeResult(self):
333
 
        return _MyResult(self.stream, self.style)
 
333
        return _MyResult(self.stream, self.descriptions, self.verbosity, self.style)
334
334
 
335
335
    # If we want the old 4 line summary output (count, 0 failures, 0 errors)
336
336
    # we can override run() too.
341
341
    InTempDir._TEST_NAME = name
342
342
    if verbose:
343
343
        style = 'verbose'
 
344
        verbosity = 2
344
345
    else:
345
346
        style = 'progress'
 
347
        verbosity = 1
346
348
    runner = TextTestRunner(stream=sys.stdout, style=style)
347
349
    result = runner.run(suite)
348
350
    # This is still a little bogus,