754
754
# want to assume that thats *all* that would happen.
755
755
self.overrideAttr(bzrlib.version, '_get_bzr_source_tree', lambda: None)
757
def test_assigned_benchmark_file_stores_date(self):
758
self._patch_get_bzr_source_tree()
760
result = bzrlib.tests.TextTestResult(self._log_file,
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.]+")
771
def test_benchhistory_records_test_times(self):
772
self._patch_get_bzr_source_tree()
773
result_stream = StringIO()
774
result = bzrlib.tests.TextTestResult(
778
bench_history=result_stream
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")
792
757
def _time_hello_world_encoding(self):
793
758
"""Profile two sleep calls
1223
1188
self.overrideAttr(bzrlib.version, '_get_bzr_source_tree', new_get)
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')
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)
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([