~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Matthieu Moy
  • Date: 2006-07-08 19:32:30 UTC
  • mfrom: (1845 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1857.
  • Revision ID: Matthieu.Moy@imag.fr-20060708193230-3eb72d871471bd5b
merge

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
 
506
507
        #           1        0            ???         ???       ???(sleep) 
507
508
        # and then repeated but with 'world', rather than 'hello'.
508
509
        # this should appear in the output stream of our test result.
509
 
        self.assertContainsRe(result_stream.getvalue(), 
510
 
            r"LSProf output for <type 'unicode'>\(\('hello',\), {'errors': 'replace'}\)\n"
511
 
            r" *CallCount *Recursive *Total\(ms\) *Inline\(ms\) *module:lineno\(function\)\n"
512
 
            r" +1 +0 +0\.\d+ +0\.\d+ +<method 'disable' of '_lsprof\.Profiler' objects>\n"
513
 
            r"LSProf output for <type 'unicode'>\(\('world',\), {'errors': 'replace'}\)\n"
514
 
            r" *CallCount *Recursive *Total\(ms\) *Inline\(ms\) *module:lineno\(function\)\n"
515
 
            r" +1 +0 +0\.\d+ +0\.\d+ +<method 'disable' of '_lsprof\.Profiler' objects>\n"
516
 
            )
 
510
        output = result_stream.getvalue()
 
511
        self.assertContainsRe(output,
 
512
            r"LSProf output for <type 'unicode'>\(\('hello',\), {'errors': 'replace'}\)")
 
513
        self.assertContainsRe(output,
 
514
            r" *CallCount *Recursive *Total\(ms\) *Inline\(ms\) *module:lineno\(function\)\n")
 
515
        self.assertContainsRe(output,
 
516
            r"( +1 +0 +0\.\d+ +0\.\d+ +<method 'disable' of '_lsprof\.Profiler' objects>\n)?")
 
517
        self.assertContainsRe(output,
 
518
            r"LSProf output for <type 'unicode'>\(\('world',\), {'errors': 'replace'}\)\n")
517
519
 
518
520
 
519
521
class TestRunner(TestCase):
679
681
        self.apply_redirected(out, err, None, bzrlib.tests.selftest, 
680
682
            test_suite_factory=factory)
681
683
        self.assertEqual([True], factory_called)
 
684
 
 
685
    def test_run_bzr_subprocess(self):
 
686
        """The run_bzr_helper_external comand behaves nicely."""
 
687
        result = self.run_bzr_subprocess('--version')
 
688
        result = self.run_bzr_subprocess('--version', retcode=None)
 
689
        self.assertContainsRe(result[0], 'is free software')
 
690
        self.assertRaises(AssertionError, self.run_bzr_subprocess, 
 
691
                          '--versionn')
 
692
        result = self.run_bzr_subprocess('--versionn', retcode=3)
 
693
        result = self.run_bzr_subprocess('--versionn', retcode=None)
 
694
        self.assertContainsRe(result[1], 'unknown command')
 
695
        err = self.run_bzr_subprocess('merge', '--merge-type', 'magic merge', 
 
696
                                      retcode=3)[1]
 
697
        self.assertContainsRe(err, 'No known merge type magic merge')
 
698
 
 
699
    def test_run_bzr_error(self):
 
700
        out, err = self.run_bzr_error(['^$'], 'rocks', retcode=0)
 
701
        self.assertEqual(out, 'it sure does!\n')
 
702
 
 
703
        out, err = self.run_bzr_error(["'foobarbaz' is not a versioned file"],
 
704
                                      'file-id', 'foobarbaz')