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