~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-31 05:16:52 UTC
  • mfrom: (5728.3.4 cleanup)
  • Revision ID: pqm@pqm.ubuntu.com-20110331051652-e24z29v6f33oylm9
(mbp) remove dead code in lockdir and fetch tests (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
754
754
        # want to assume that thats *all* that would happen.
755
755
        self.overrideAttr(bzrlib.version, '_get_bzr_source_tree', lambda: None)
756
756
 
757
 
    def test_assigned_benchmark_file_stores_date(self):
758
 
        self._patch_get_bzr_source_tree()
759
 
        output = StringIO()
760
 
        result = bzrlib.tests.TextTestResult(self._log_file,
761
 
                                        descriptions=0,
762
 
                                        verbosity=1,
763
 
                                        bench_history=output
764
 
                                        )
765
 
        output_string = output.getvalue()
766
 
        # if you are wondering about the regexp please read the comment in
767
 
        # test_bench_history (bzrlib.tests.test_selftest.TestRunner)
768
 
        # XXX: what comment?  -- Andrew Bennetts
769
 
        self.assertContainsRe(output_string, "--date [0-9.]+")
770
 
 
771
 
    def test_benchhistory_records_test_times(self):
772
 
        self._patch_get_bzr_source_tree()
773
 
        result_stream = StringIO()
774
 
        result = bzrlib.tests.TextTestResult(
775
 
            self._log_file,
776
 
            descriptions=0,
777
 
            verbosity=1,
778
 
            bench_history=result_stream
779
 
            )
780
 
 
781
 
        # we want profile a call and check that its test duration is recorded
782
 
        # make a new test instance that when run will generate a benchmark
783
 
        example_test_case = TestTestResult("_time_hello_world_encoding")
784
 
        # execute the test, which should succeed and record times
785
 
        example_test_case.run(result)
786
 
        lines = result_stream.getvalue().splitlines()
787
 
        self.assertEqual(2, len(lines))
788
 
        self.assertContainsRe(lines[1],
789
 
            " *[0-9]+ms bzrlib.tests.test_selftest.TestTestResult"
790
 
            "._time_hello_world_encoding")
791
 
 
792
757
    def _time_hello_world_encoding(self):
793
758
        """Profile two sleep calls
794
759
 
1222
1187
            return None
1223
1188
        self.overrideAttr(bzrlib.version, '_get_bzr_source_tree',  new_get)
1224
1189
 
1225
 
    def test_bench_history(self):
1226
 
        # tests that the running the benchmark passes bench_history into
1227
 
        # the test result object. We can tell that happens if
1228
 
        # _get_bzr_source_tree is called.
1229
 
        self._patch_get_bzr_source_tree()
1230
 
        test = TestRunner('dummy_test')
1231
 
        output = StringIO()
1232
 
        runner = tests.TextTestRunner(stream=self._log_file,
1233
 
                                      bench_history=output)
1234
 
        result = self.run_test_runner(runner, test)
1235
 
        output_string = output.getvalue()
1236
 
        self.assertContainsRe(output_string, "--date [0-9.]+")
1237
 
        self.assertLength(1, self._get_source_tree_calls)
1238
 
 
1239
1190
    def test_verbose_test_count(self):
1240
1191
        """A verbose test run reports the right test count at the start"""
1241
1192
        suite = TestUtil.TestSuite([