405
409
mypb = MockProgress()
406
410
mypb.update('Running tests', 0, 4)
407
411
last_calls = mypb.calls[:]
408
413
result = bzrlib.tests._MyResult(self._log_file,
412
417
self.assertEqual(last_calls, mypb.calls)
420
"""Shorten a string based on the terminal width"""
421
return result._ellipsise_unimportant_words(s,
422
osutils.terminal_width())
415
425
result.startTest(dummy_test)
416
426
# starting a test prints the test name
417
self.assertEqual(last_calls + [('update', '...tyle_quiet', 0, None)], mypb.calls)
418
last_calls = mypb.calls[:]
427
last_calls += [('update', '...tyle_quiet', 0, None)]
428
self.assertEqual(last_calls, mypb.calls)
419
429
result.addError(dummy_test, dummy_error)
420
self.assertEqual(last_calls + [('update', 'ERROR ', 1, None)], mypb.calls)
421
last_calls = mypb.calls[:]
430
last_calls += [('update', 'ERROR ', 1, None),
431
('note', shorten(dummy_test.id() + ': ERROR'), ())
433
self.assertEqual(last_calls, mypb.calls)
424
436
result.startTest(dummy_test)
425
self.assertEqual(last_calls + [('update', '...tyle_quiet', 1, None)], mypb.calls)
426
last_calls = mypb.calls[:]
437
last_calls += [('update', '...tyle_quiet', 1, None)]
438
self.assertEqual(last_calls, mypb.calls)
439
last_calls += [('update', 'FAIL ', 2, None),
440
('note', shorten(dummy_test.id() + ': FAIL'), ())
427
442
result.addFailure(dummy_test, dummy_error)
428
self.assertEqual(last_calls + [('update', 'FAIL ', 2, None)], mypb.calls)
429
last_calls = mypb.calls[:]
443
self.assertEqual(last_calls, mypb.calls)
432
446
result.startTest(dummy_test)
433
self.assertEqual(last_calls + [('update', '...tyle_quiet', 2, None)], mypb.calls)
434
last_calls = mypb.calls[:]
447
last_calls += [('update', '...tyle_quiet', 2, None)]
448
self.assertEqual(last_calls, mypb.calls)
435
449
result.addSuccess(dummy_test)
436
self.assertEqual(last_calls + [('update', 'OK ', 3, None)], mypb.calls)
437
last_calls = mypb.calls[:]
450
last_calls += [('update', 'OK ', 3, None)]
451
self.assertEqual(last_calls, mypb.calls)
440
454
result.startTest(dummy_test)
441
self.assertEqual(last_calls + [('update', '...tyle_quiet', 3, None)], mypb.calls)
442
last_calls = mypb.calls[:]
455
last_calls += [('update', '...tyle_quiet', 3, None)]
456
self.assertEqual(last_calls, mypb.calls)
443
457
result.addSkipped(dummy_test, dummy_error)
444
self.assertEqual(last_calls + [('update', 'SKIP ', 4, None)], mypb.calls)
445
last_calls = mypb.calls[:]
458
last_calls += [('update', 'SKIP ', 4, None)]
459
self.assertEqual(last_calls, mypb.calls)
447
461
def test_elapsed_time_with_benchmarking(self):
448
462
result = bzrlib.tests._MyResult(self._log_file,