/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

Make test_bench_history and _get_bzr_source_tree tolerant of UnknownFormatError for the bzr workingtree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
import bzrlib.errors as errors
39
39
from bzrlib import symbol_versioning
40
40
from bzrlib.trace import note
 
41
from bzrlib.version import _get_bzr_source_tree
41
42
 
42
43
 
43
44
class SelftestTests(TestCase):
705
706
        self.assertTrue(result.wasSuccessful())
706
707
 
707
708
    def test_bench_history(self):
708
 
        import bzrlib.branch
709
 
        try:
710
 
            branch = bzrlib.branch.Branch.open_containing(__file__)[0]
711
 
        except errors.NotBranchError:
712
 
            raise TestSkipped(
713
 
                'Test must be run in a bzr.dev tree, not an installed copy.')
 
709
        # tests that the running the benchmark produces a history file
 
710
        # containing a timestamp and the revision id of the bzrlib source which
 
711
        # was tested.
 
712
        workingtree = _get_bzr_source_tree()
714
713
        test = TestRunner('dummy_test')
715
714
        output = StringIO()
716
715
        runner = TextTestRunner(stream=self._log_file, bench_history=output)
717
716
        result = self.run_test_runner(runner, test)
718
717
        output_string = output.getvalue()
719
 
        self.assertContainsRe(output_string, "--date [0-9.]+ \S")
720
 
        revision_id = branch.last_revision()
721
 
        self.assertEndsWith(output_string.rstrip(), revision_id)
 
718
        self.assertContainsRe(output_string, "--date [0-9.]+")
 
719
        if workingtree is not None:
 
720
            revision_id = workingtree.last_revision()
 
721
            self.assertEndsWith(output_string.rstrip(), revision_id)
722
722
 
723
723
 
724
724
class TestTestCase(TestCase):