450
454
mypb = MockProgress()
451
455
mypb.update('Running tests', 0, 4)
452
456
last_calls = mypb.calls[:]
453
458
result = bzrlib.tests._MyResult(self._log_file,
457
462
self.assertEqual(last_calls, mypb.calls)
465
"""Shorten a string based on the terminal width"""
466
return result._ellipsise_unimportant_words(s,
467
osutils.terminal_width())
460
470
result.startTest(dummy_test)
461
471
# starting a test prints the test name
462
self.assertEqual(last_calls + [('update', '...tyle_quiet', 0, None)], mypb.calls)
463
last_calls = mypb.calls[:]
472
last_calls += [('update', '...tyle_quiet', 0, None)]
473
self.assertEqual(last_calls, mypb.calls)
464
474
result.addError(dummy_test, dummy_error)
465
self.assertEqual(last_calls + [('update', 'ERROR ', 1, None)], mypb.calls)
466
last_calls = mypb.calls[:]
475
last_calls += [('update', 'ERROR ', 1, None),
476
('note', shorten(dummy_test.id() + ': ERROR'), ())
478
self.assertEqual(last_calls, mypb.calls)
469
481
result.startTest(dummy_test)
470
self.assertEqual(last_calls + [('update', '...tyle_quiet', 1, None)], mypb.calls)
471
last_calls = mypb.calls[:]
482
last_calls += [('update', '...tyle_quiet', 1, None)]
483
self.assertEqual(last_calls, mypb.calls)
484
last_calls += [('update', 'FAIL ', 2, None),
485
('note', shorten(dummy_test.id() + ': FAIL'), ())
472
487
result.addFailure(dummy_test, dummy_error)
473
self.assertEqual(last_calls + [('update', 'FAIL ', 2, None)], mypb.calls)
474
last_calls = mypb.calls[:]
488
self.assertEqual(last_calls, mypb.calls)
477
491
result.startTest(dummy_test)
478
self.assertEqual(last_calls + [('update', '...tyle_quiet', 2, None)], mypb.calls)
479
last_calls = mypb.calls[:]
492
last_calls += [('update', '...tyle_quiet', 2, None)]
493
self.assertEqual(last_calls, mypb.calls)
480
494
result.addSuccess(dummy_test)
481
self.assertEqual(last_calls + [('update', 'OK ', 3, None)], mypb.calls)
482
last_calls = mypb.calls[:]
495
last_calls += [('update', 'OK ', 3, None)]
496
self.assertEqual(last_calls, mypb.calls)
485
499
result.startTest(dummy_test)
486
self.assertEqual(last_calls + [('update', '...tyle_quiet', 3, None)], mypb.calls)
487
last_calls = mypb.calls[:]
500
last_calls += [('update', '...tyle_quiet', 3, None)]
501
self.assertEqual(last_calls, mypb.calls)
488
502
result.addSkipped(dummy_test, dummy_error)
489
self.assertEqual(last_calls + [('update', 'SKIP ', 4, None)], mypb.calls)
490
last_calls = mypb.calls[:]
503
last_calls += [('update', 'SKIP ', 4, None)]
504
self.assertEqual(last_calls, mypb.calls)
492
506
def test_elapsed_time_with_benchmarking(self):
493
507
result = bzrlib.tests._MyResult(self._log_file,
726
740
self.apply_redirected(out, err, None, bzrlib.tests.selftest,
727
741
test_suite_factory=factory)
728
742
self.assertEqual([True], factory_called)
730
def test_run_bzr_subprocess(self):
731
"""The run_bzr_helper_external comand behaves nicely."""
732
result = self.run_bzr_subprocess('--version')
733
result = self.run_bzr_subprocess('--version', retcode=None)
734
self.assertContainsRe(result[0], 'is free software')
735
self.assertRaises(AssertionError, self.run_bzr_subprocess,
737
result = self.run_bzr_subprocess('--versionn', retcode=3)
738
result = self.run_bzr_subprocess('--versionn', retcode=None)
739
self.assertContainsRe(result[1], 'unknown command')
740
err = self.run_bzr_subprocess('merge', '--merge-type', 'magic merge',
742
self.assertContainsRe(err, 'No known merge type magic merge')
744
def test_run_bzr_error(self):
745
out, err = self.run_bzr_error(['^$'], 'rocks', retcode=0)
746
self.assertEqual(out, 'it sure does!\n')
748
out, err = self.run_bzr_error(["'foobarbaz' is not a versioned file"],
749
'file-id', 'foobarbaz')