/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

Merge bzr.dev.

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):
587
588
        output_string = output.getvalue()
588
589
        # if you are wondering about the regexp please read the comment in
589
590
        # test_bench_history (bzrlib.tests.test_selftest.TestRunner)
590
 
        self.assertContainsRe(output_string, "--date [0-9.]+ \S")
 
591
        # XXX: what comment?  -- Andrew Bennetts
 
592
        self.assertContainsRe(output_string, "--date [0-9.]+")
591
593
 
592
594
    def test_benchhistory_records_test_times(self):
593
595
        result_stream = StringIO()
705
707
        self.assertTrue(result.wasSuccessful())
706
708
 
707
709
    def test_bench_history(self):
708
 
        import bzrlib.branch
709
 
        import bzrlib.revisionspec
 
710
        # tests that the running the benchmark produces a history file
 
711
        # containing a timestamp and the revision id of the bzrlib source which
 
712
        # was tested.
 
713
        workingtree = _get_bzr_source_tree()
710
714
        test = TestRunner('dummy_test')
711
715
        output = StringIO()
712
716
        runner = TextTestRunner(stream=self._log_file, bench_history=output)
713
717
        result = self.run_test_runner(runner, test)
714
718
        output_string = output.getvalue()
715
 
        # does anyone know a good regexp for revision ids?
716
 
        # here we are using \S instead and checking the revision id afterwards
717
 
        self.assertContainsRe(output_string, "--date [0-9.]+ \S")
718
 
        branch = bzrlib.branch.Branch.open_containing('.')[0]
719
 
        revision_id = bzrlib.revisionspec.RevisionSpec(branch.revno()).in_history(branch).rev_id
720
 
        self.assert_(output_string.rstrip().endswith(revision_id))
 
719
        self.assertContainsRe(output_string, "--date [0-9.]+")
 
720
        if workingtree is not None:
 
721
            revision_id = workingtree.last_revision()
 
722
            self.assertEndsWith(output_string.rstrip(), revision_id)
721
723
 
722
724
 
723
725
class TestTestCase(TestCase):
809
811
        self.assertEndsWith('foo', 'oo')
810
812
        self.assertRaises(AssertionError, self.assertEndsWith, 'o', 'oo')
811
813
 
812
 
    def test_assertDeprecated(self):
813
 
        def testfunc(be_deprecated):
 
814
    def test_callDeprecated(self):
 
815
        def testfunc(be_deprecated, result=None):
814
816
            if be_deprecated is True:
815
817
                symbol_versioning.warn('i am deprecated', DeprecationWarning, 
816
818
                                       stacklevel=1)
817
 
        self.assertDeprecated(['i am deprecated'], testfunc, True)
818
 
        self.assertDeprecated([], testfunc, False)
819
 
        self.assertDeprecated(['i am deprecated'], testfunc, 
 
819
            return result
 
820
        result = self.callDeprecated(['i am deprecated'], testfunc, True)
 
821
        self.assertIs(None, result)
 
822
        result = self.callDeprecated([], testfunc, False, 'result')
 
823
        self.assertEqual('result', result)
 
824
        self.callDeprecated(['i am deprecated'], testfunc, 
820
825
                              be_deprecated=True)
821
 
        self.assertDeprecated([], testfunc, be_deprecated=False)
 
826
        self.callDeprecated([], testfunc, be_deprecated=False)
822
827
 
823
828
 
824
829
class TestConvenienceMakers(TestCaseWithTransport):