~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Gary van der Merwe
  • Date: 2010-08-02 19:56:52 UTC
  • mfrom: (5050.3.18 2.2)
  • mto: (5050.3.19 2.2)
  • mto: This revision was merged to the branch mainline in revision 5371.
  • Revision ID: garyvdm@gmail.com-20100802195652-o1ppjemhwrr98i61
MergeĀ lp:bzr/2.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    )
63
63
from bzrlib.tests import (
64
64
    features,
65
 
    stub_sftp,
66
65
    test_lsprof,
67
66
    test_server,
68
67
    test_sftp_transport,
610
609
                l.attempt_lock()
611
610
        test = TestDanglingLock('test_function')
612
611
        result = test.run()
 
612
        total_failures = result.errors + result.failures
613
613
        if self._lock_check_thorough:
614
 
            self.assertEqual(1, len(result.errors))
 
614
            self.assertLength(1, total_failures)
615
615
        else:
616
616
            # When _lock_check_thorough is disabled, then we don't trigger a
617
617
            # failure
618
 
            self.assertEqual(0, len(result.errors))
 
618
            self.assertLength(0, total_failures)
619
619
 
620
620
 
621
621
class TestTestCaseWithTransport(tests.TestCaseWithTransport):
622
622
    """Tests for the convenience functions TestCaseWithTransport introduces."""
623
623
 
624
624
    def test_get_readonly_url_none(self):
625
 
        from bzrlib.transport import get_transport
626
625
        from bzrlib.transport.readonly import ReadonlyTransportDecorator
627
626
        self.vfs_transport_factory = memory.MemoryServer
628
627
        self.transport_readonly_server = None
630
629
        # for the server
631
630
        url = self.get_readonly_url()
632
631
        url2 = self.get_readonly_url('foo/bar')
633
 
        t = get_transport(url)
634
 
        t2 = get_transport(url2)
 
632
        t = transport.get_transport(url)
 
633
        t2 = transport.get_transport(url2)
635
634
        self.failUnless(isinstance(t, ReadonlyTransportDecorator))
636
635
        self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
637
636
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
638
637
 
639
638
    def test_get_readonly_url_http(self):
640
639
        from bzrlib.tests.http_server import HttpServer
641
 
        from bzrlib.transport import get_transport
642
640
        from bzrlib.transport.http import HttpTransportBase
643
641
        self.transport_server = test_server.LocalURLServer
644
642
        self.transport_readonly_server = HttpServer
646
644
        url = self.get_readonly_url()
647
645
        url2 = self.get_readonly_url('foo/bar')
648
646
        # the transport returned may be any HttpTransportBase subclass
649
 
        t = get_transport(url)
650
 
        t2 = get_transport(url2)
 
647
        t = transport.get_transport(url)
 
648
        t2 = transport.get_transport(url2)
651
649
        self.failUnless(isinstance(t, HttpTransportBase))
652
650
        self.failUnless(isinstance(t2, HttpTransportBase))
653
651
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
691
689
class TestChrootedTest(tests.ChrootedTestCase):
692
690
 
693
691
    def test_root_is_root(self):
694
 
        from bzrlib.transport import get_transport
695
 
        t = get_transport(self.get_readonly_url())
 
692
        t = transport.get_transport(self.get_readonly_url())
696
693
        url = t.base
697
694
        self.assertEqual(url, t.clone('..').base)
698
695
 
1947
1944
 
1948
1945
    def test_transport_sftp(self):
1949
1946
        self.requireFeature(features.paramiko)
 
1947
        from bzrlib.tests import stub_sftp
1950
1948
        self.check_transport_set(stub_sftp.SFTPAbsoluteServer)
1951
1949
 
1952
1950
    def test_transport_memory(self):
2773
2771
        # Test that a plausible list of modules to doctest is returned
2774
2772
        # by _test_suite_modules_to_doctest.
2775
2773
        test_list = tests._test_suite_modules_to_doctest()
 
2774
        if __doc__ is None:
 
2775
            # When docstrings are stripped, there are no modules to doctest
 
2776
            self.assertEqual([], test_list)
 
2777
            return
2776
2778
        self.assertSubset([
2777
2779
            'bzrlib.timestamp',
2778
2780
            ],
2795
2797
        self.overrideAttr(tests, '_test_suite_testmod_names', testmod_names)
2796
2798
        def doctests():
2797
2799
            calls.append("modules_to_doctest")
 
2800
            if __doc__ is None:
 
2801
                return []
2798
2802
            return ['bzrlib.timestamp']
2799
2803
        self.overrideAttr(tests, '_test_suite_modules_to_doctest', doctests)
2800
2804
        expected_test_list = [
2803
2807
            ('bzrlib.tests.per_transport.TransportTests'
2804
2808
             '.test_abspath(LocalTransport,LocalURLServer)'),
2805
2809
            'bzrlib.tests.test_selftest.TestTestSuite.test_test_suite',
2806
 
            # modules_to_doctest
2807
 
            'bzrlib.timestamp.format_highres_date',
2808
2810
            # plugins can't be tested that way since selftest may be run with
2809
2811
            # --no-plugins
2810
2812
            ]
 
2813
        if __doc__ is not None:
 
2814
            expected_test_list.extend([
 
2815
                # modules_to_doctest
 
2816
                'bzrlib.timestamp.format_highres_date',
 
2817
                ])
2811
2818
        suite = tests.test_suite()
2812
2819
        self.assertEqual(set(["testmod_names", "modules_to_doctest"]),
2813
2820
            set(calls))