/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2007-06-15 07:01:24 UTC
  • mfrom: (2528 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2530.
  • Revision ID: mbp@sourcefrog.net-20070615070124-clpwqh5gxc4wbf9l
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                          iter_suite_tests,
55
55
                          filter_suite_by_re,
56
56
                          sort_suite_by_re,
57
 
                          test_suite
 
57
                          test_lsprof,
 
58
                          test_suite,
58
59
                          )
59
60
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
60
61
from bzrlib.tests.TestUtil import _load_module_by_name
620
621
        result.extractBenchmarkTime(self)
621
622
        timed_string = result._testTimeString()
622
623
        # without explicit benchmarking, we should get a simple time.
623
 
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms$")
 
624
        self.assertContainsRe(timed_string, "^ +[0-9]+ms$")
624
625
        # if a benchmark time is given, we want a x of y style result.
625
626
        self.time(time.sleep, 0.001)
626
627
        result.extractBenchmarkTime(self)
627
628
        timed_string = result._testTimeString()
628
 
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms/ *[ 1-9][0-9]ms$")
 
629
        self.assertContainsRe(
 
630
            timed_string, "^ +[0-9]+ms/ +[0-9]+ms$")
629
631
        # extracting the time from a non-bzrlib testcase sets to None
630
632
        result._recordTestStartTime()
631
633
        result.extractBenchmarkTime(
632
634
            unittest.FunctionTestCase(self.test_elapsed_time_with_benchmarking))
633
635
        timed_string = result._testTimeString()
634
 
        self.assertContainsRe(timed_string, "^ *[ 1-9][0-9]ms$")
 
636
        self.assertContainsRe(timed_string, "^ +[0-9]+ms$")
635
637
        # cheat. Yes, wash thy mouth out with soap.
636
638
        self._benchtime = None
637
639
 
679
681
 
680
682
    def test_lsprofiling(self):
681
683
        """Verbose test result prints lsprof statistics from test cases."""
682
 
        try:
683
 
            import bzrlib.lsprof
684
 
        except ImportError:
685
 
            raise TestSkipped("lsprof not installed.")
 
684
        self.requireFeature(test_lsprof.LSProf())
686
685
        result_stream = StringIO()
687
686
        result = bzrlib.tests.VerboseTestResult(
688
687
            unittest._WritelnDecorator(result_stream),
1194
1193
        
1195
1194
        Each self.time() call is individually and separately profiled.
1196
1195
        """
1197
 
        try:
1198
 
            import bzrlib.lsprof
1199
 
        except ImportError:
1200
 
            raise TestSkipped("lsprof not installed.")
 
1196
        self.requireFeature(test_lsprof.LSProf())
1201
1197
        # overrides the class member with an instance member so no cleanup 
1202
1198
        # needed.
1203
1199
        self._gather_lsprof_in_benchmarks = True