/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: Canonical.com Patch Queue Manager
  • Date: 2010-09-03 02:53:10 UTC
  • mfrom: (5404.2.1 2.3-test-loader)
  • Revision ID: pqm@pqm.ubuntu.com-20100903025310-t8mj1bjq4fsyxk7p
(jameinel) Restore TestSuite and TestLoader as attributes of bzrlib.tests
 (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        self.failUnlessExists(filename)
123
123
 
124
124
 
 
125
class TestClassesAvailable(tests.TestCase):
 
126
    """As a convenience we expose Test* classes from bzrlib.tests"""
 
127
 
 
128
    def test_test_case(self):
 
129
        from bzrlib.tests import TestCase
 
130
 
 
131
    def test_test_loader(self):
 
132
        from bzrlib.tests import TestLoader
 
133
 
 
134
    def test_test_suite(self):
 
135
        from bzrlib.tests import TestSuite
 
136
 
 
137
 
125
138
class TestTransportScenarios(tests.TestCase):
126
139
    """A group of tests that test the transport implementation adaption core.
127
140
 
208
221
    def test_scenarios(self):
209
222
        # check that constructor parameters are passed through to the adapted
210
223
        # test.
211
 
        from bzrlib.tests.per_bzrdir import make_scenarios
 
224
        from bzrlib.tests.per_controldir import make_scenarios
212
225
        vfs_factory = "v"
213
226
        server1 = "a"
214
227
        server2 = "b"
609
622
                l.attempt_lock()
610
623
        test = TestDanglingLock('test_function')
611
624
        result = test.run()
 
625
        total_failures = result.errors + result.failures
612
626
        if self._lock_check_thorough:
613
 
            self.assertEqual(1, len(result.errors))
 
627
            self.assertLength(1, total_failures)
614
628
        else:
615
629
            # When _lock_check_thorough is disabled, then we don't trigger a
616
630
            # failure
617
 
            self.assertEqual(0, len(result.errors))
 
631
            self.assertLength(0, total_failures)
618
632
 
619
633
 
620
634
class TestTestCaseWithTransport(tests.TestCaseWithTransport):
621
635
    """Tests for the convenience functions TestCaseWithTransport introduces."""
622
636
 
623
637
    def test_get_readonly_url_none(self):
624
 
        from bzrlib.transport import get_transport
625
638
        from bzrlib.transport.readonly import ReadonlyTransportDecorator
626
639
        self.vfs_transport_factory = memory.MemoryServer
627
640
        self.transport_readonly_server = None
629
642
        # for the server
630
643
        url = self.get_readonly_url()
631
644
        url2 = self.get_readonly_url('foo/bar')
632
 
        t = get_transport(url)
633
 
        t2 = get_transport(url2)
 
645
        t = transport.get_transport(url)
 
646
        t2 = transport.get_transport(url2)
634
647
        self.failUnless(isinstance(t, ReadonlyTransportDecorator))
635
648
        self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
636
649
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
637
650
 
638
651
    def test_get_readonly_url_http(self):
639
652
        from bzrlib.tests.http_server import HttpServer
640
 
        from bzrlib.transport import get_transport
641
653
        from bzrlib.transport.http import HttpTransportBase
642
654
        self.transport_server = test_server.LocalURLServer
643
655
        self.transport_readonly_server = HttpServer
645
657
        url = self.get_readonly_url()
646
658
        url2 = self.get_readonly_url('foo/bar')
647
659
        # the transport returned may be any HttpTransportBase subclass
648
 
        t = get_transport(url)
649
 
        t2 = get_transport(url2)
 
660
        t = transport.get_transport(url)
 
661
        t2 = transport.get_transport(url2)
650
662
        self.failUnless(isinstance(t, HttpTransportBase))
651
663
        self.failUnless(isinstance(t2, HttpTransportBase))
652
664
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
690
702
class TestChrootedTest(tests.ChrootedTestCase):
691
703
 
692
704
    def test_root_is_root(self):
693
 
        from bzrlib.transport import get_transport
694
 
        t = get_transport(self.get_readonly_url())
 
705
        t = transport.get_transport(self.get_readonly_url())
695
706
        url = t.base
696
707
        self.assertEqual(url, t.clone('..').base)
697
708
 
803
814
        self.requireFeature(test_lsprof.LSProfFeature)
804
815
        result_stream = StringIO()
805
816
        result = bzrlib.tests.VerboseTestResult(
806
 
            unittest._WritelnDecorator(result_stream),
 
817
            result_stream,
807
818
            descriptions=0,
808
819
            verbosity=2,
809
820
            )
864
875
        # verbose test output formatting
865
876
        result_stream = StringIO()
866
877
        result = bzrlib.tests.VerboseTestResult(
867
 
            unittest._WritelnDecorator(result_stream),
 
878
            result_stream,
868
879
            descriptions=0,
869
880
            verbosity=2,
870
881
            )
880
891
        output = result_stream.getvalue()[prefix:]
881
892
        lines = output.splitlines()
882
893
        self.assertContainsRe(lines[0], r'XFAIL *\d+ms$')
 
894
        if sys.version_info > (2, 7):
 
895
            self.expectFailure("_ExpectedFailure on 2.7 loses the message",
 
896
                self.assertNotEqual, lines[1], '    ')
883
897
        self.assertEqual(lines[1], '    foo')
884
898
        self.assertEqual(2, len(lines))
885
899
 
919
933
        # verbose test output formatting
920
934
        result_stream = StringIO()
921
935
        result = bzrlib.tests.VerboseTestResult(
922
 
            unittest._WritelnDecorator(result_stream),
 
936
            result_stream,
923
937
            descriptions=0,
924
938
            verbosity=2,
925
939
            )
1421
1435
        sample_test = TestTestCase("method_that_times_a_bit_twice")
1422
1436
        output_stream = StringIO()
1423
1437
        result = bzrlib.tests.VerboseTestResult(
1424
 
            unittest._WritelnDecorator(output_stream),
 
1438
            output_stream,
1425
1439
            descriptions=0,
1426
1440
            verbosity=2)
1427
1441
        sample_test.run(result)
2339
2353
            os.chdir = orig_chdir
2340
2354
        self.assertEqual(['foo', 'current'], chdirs)
2341
2355
 
 
2356
    def test_get_bzr_path_with_cwd_bzrlib(self):
 
2357
        self.get_source_path = lambda: ""
 
2358
        self.overrideAttr(os.path, "isfile", lambda path: True)
 
2359
        self.assertEqual(self.get_bzr_path(), "bzr")
 
2360
 
2342
2361
 
2343
2362
class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport):
2344
2363
    """Tests that really need to do things with an external bzr."""