~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testsweet.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
        self.log("check contents of file %s" % filename)
200
200
        contents = file(filename, 'r').read()
201
201
        if contents != expect:
202
 
            self.log("expected: %r" % expect)
 
202
            self.log("expected: %r" % expected)
203
203
            self.log("actually: %r" % contents)
204
204
            self.fail("contents of %s not as expected")
205
205
            
227
227
 
228
228
    No special behaviour for now.
229
229
    """
230
 
    def __init__(self, out, style):
 
230
    def __init__(self, out):
231
231
        self.out = out
232
232
        TestResult.__init__(self)
233
 
        assert style in ('none', 'progress', 'verbose')
234
 
        self.style = style
235
 
 
236
233
 
237
234
    def startTest(self, test):
238
235
        # TODO: Maybe show test.shortDescription somewhere?
241
238
        if what == 'runit':
242
239
            what = test.shortDescription()
243
240
        
244
 
        if self.style == 'verbose':
245
 
            print >>self.out, '%-60.60s' % what,
246
 
            self.out.flush()
247
 
        elif self.style == 'progress':
248
 
            self.out.write('~')
249
 
            self.out.flush()
 
241
        print >>self.out, '%-60.60s' % what,
 
242
        self.out.flush()
250
243
        TestResult.startTest(self, test)
251
244
 
252
 
 
253
245
    def stopTest(self, test):
254
246
        # print
255
247
        TestResult.stopTest(self, test)
256
248
 
257
249
 
258
250
    def addError(self, test, err):
259
 
        if self.style == 'verbose':
260
 
            print >>self.out, 'ERROR'
 
251
        print >>self.out, 'ERROR'
261
252
        TestResult.addError(self, test, err)
262
253
        _show_test_failure('error', test, err, self.out)
263
254
 
264
255
    def addFailure(self, test, err):
265
 
        if self.style == 'verbose':
266
 
            print >>self.out, 'FAILURE'
 
256
        print >>self.out, 'FAILURE'
267
257
        TestResult.addFailure(self, test, err)
268
258
        _show_test_failure('failure', test, err, self.out)
269
259
 
270
260
    def addSuccess(self, test):
271
 
        if self.style == 'verbose':
272
 
            print >>self.out, 'OK'
 
261
        print >>self.out, 'OK'
273
262
        TestResult.addSuccess(self, test)
274
263
 
275
264
 
276
265
 
277
 
def run_suite(suite, name='test', verbose=False):
 
266
def run_suite(suite, name="test"):
278
267
    import os
279
268
    import shutil
280
269
    import time
289
278
    real_stderr = sys.stderr
290
279
    sys.stdout = sys.stderr = TestBase.TEST_LOG
291
280
    try:
292
 
        if verbose:
293
 
            style = 'verbose'
294
 
        else:
295
 
            style = 'progress'
296
 
        result = _MyResult(real_stdout, style)
 
281
        result = _MyResult(real_stdout)
297
282
        suite.run(result)
298
283
    finally:
299
284
        sys.stdout = real_stdout