~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2006-06-20 07:55:43 UTC
  • mfrom: (1798 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1799.
  • Revision ID: mbp@sourcefrog.net-20060620075543-b10f6575d4a4fa32
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                          )
36
36
from bzrlib.tests.TestUtil import _load_module_by_name
37
37
import bzrlib.errors as errors
 
38
from bzrlib.trace import note
38
39
 
39
40
 
40
41
class SelftestTests(TestCase):
458
459
        self.time(time.sleep, 0.001)
459
460
        result.extractBenchmarkTime(self)
460
461
        timed_string = result._testTimeString()
461
 
        self.assertContainsRe(timed_string, "^    [0-9]ms/   [ 1-9][0-9]ms$")
 
462
        self.assertContainsRe(timed_string, "^   [ 1-9][0-9]ms/   [ 1-9][0-9]ms$")
462
463
        # extracting the time from a non-bzrlib testcase sets to None
463
464
        result._recordTestStartTime()
464
465
        result.extractBenchmarkTime(
465
466
            unittest.FunctionTestCase(self.test_elapsed_time_with_benchmarking))
466
467
        timed_string = result._testTimeString()
467
 
        self.assertContainsRe(timed_string, "^          [0-9]ms$")
 
468
        self.assertContainsRe(timed_string, "^         [ 1-9][0-9]ms$")
468
469
        # cheat. Yes, wash thy mouth out with soap.
469
470
        self._benchtime = None
470
471
 
679
680
        self.apply_redirected(out, err, None, bzrlib.tests.selftest, 
680
681
            test_suite_factory=factory)
681
682
        self.assertEqual([True], factory_called)
 
683
 
 
684
    def test_run_bzr_subprocess(self):
 
685
        """The run_bzr_helper_external comand behaves nicely."""
 
686
        result = self.run_bzr_subprocess('--version')
 
687
        result = self.run_bzr_subprocess('--version', retcode=None)
 
688
        self.assertContainsRe(result[0], 'is free software')
 
689
        self.assertRaises(AssertionError, self.run_bzr_subprocess, 
 
690
                          '--versionn')
 
691
        result = self.run_bzr_subprocess('--versionn', retcode=3)
 
692
        result = self.run_bzr_subprocess('--versionn', retcode=None)
 
693
        self.assertContainsRe(result[1], 'unknown command')
 
694
        err = self.run_bzr_subprocess('merge', '--merge-type', 'magic merge', 
 
695
                                      retcode=3)[1]
 
696
        self.assertContainsRe(err, 'No known merge type magic merge')