265
265
No special behaviour for now.
267
def __init__(self, stream, descriptions, verbosity, style):
268
super(_MyResult, self).__init__(stream, descriptions, verbosity)
270
assert style in ('none', 'progress', 'verbose')
273
268
def startTest(self, test):
274
super(_MyResult, self).startTest(test)
269
unittest.TestResult.startTest(self, test)
275
270
# TODO: Maybe show test.shortDescription somewhere?
277
272
# python2.3 has the bad habit of just "runit" for doctests
278
273
if what == 'runit':
279
274
what = test.shortDescription()
280
if self.style == 'verbose':
281
print >>self.stream, '%-60.60s' % what,
276
self.stream.write('%-60.60s' % what)
284
279
def addError(self, test, err):
285
if self.style == 'verbose':
286
print >>self.stream, 'ERROR'
287
elif self.style == 'progress':
288
self.stream.write('E')
290
280
super(_MyResult, self).addError(test, err)
292
283
def addFailure(self, test, err):
293
if self.style == 'verbose':
294
print >>self.stream, 'FAILURE'
295
elif self.style == 'progress':
296
self.stream.write('F')
298
284
super(_MyResult, self).addFailure(test, err)
300
287
def addSuccess(self, test):
301
if self.style == 'verbose':
302
print >>self.stream, 'OK'
303
elif self.style == 'progress':
289
self.stream.writeln('OK')
304
291
self.stream.write('~')
305
292
self.stream.flush()
306
super(_MyResult, self).addSuccess(test)
308
def printErrors(self):
309
if self.style == 'progress':
310
self.stream.writeln()
311
super(_MyResult, self).printErrors()
293
unittest.TestResult.addSuccess(self, test)
313
295
def printErrorList(self, flavour, errors):
314
296
for test, err in errors:
326
308
class TextTestRunner(unittest.TextTestRunner):
328
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=0, style='progress'):
310
def __init__(self, stream=sys.stderr, descriptions=0, verbosity=1):
329
311
super(TextTestRunner, self).__init__(stream, descriptions, verbosity)
332
313
def _makeResult(self):
333
return _MyResult(self.stream, self.descriptions, self.verbosity, self.style)
314
return _MyResult(self.stream, self.descriptions, self.verbosity)
335
316
# If we want the old 4 line summary output (count, 0 failures, 0 errors)
336
317
# we can override run() too.
341
322
InTempDir._TEST_NAME = name
348
runner = TextTestRunner(stream=sys.stdout, style=style)
327
runner = TextTestRunner(stream=sys.stdout, verbosity=verbosity)
349
328
result = runner.run(suite)
350
329
# This is still a little bogus,
351
330
# but only a little. Folk not using our testrunner will