/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: Jelmer Vernooij
  • Date: 2010-08-20 19:07:17 UTC
  • mfrom: (5385 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5389.
  • Revision ID: jelmer@samba.org-20100820190717-txm7aiyh6wtumgd3
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
208
208
    def test_scenarios(self):
209
209
        # check that constructor parameters are passed through to the adapted
210
210
        # test.
211
 
        from bzrlib.tests.per_bzrdir import make_scenarios
 
211
        from bzrlib.tests.per_controldir import make_scenarios
212
212
        vfs_factory = "v"
213
213
        server1 = "a"
214
214
        server2 = "b"
609
609
                l.attempt_lock()
610
610
        test = TestDanglingLock('test_function')
611
611
        result = test.run()
 
612
        total_failures = result.errors + result.failures
612
613
        if self._lock_check_thorough:
613
 
            self.assertEqual(1, len(result.errors))
 
614
            self.assertLength(1, total_failures)
614
615
        else:
615
616
            # When _lock_check_thorough is disabled, then we don't trigger a
616
617
            # failure
617
 
            self.assertEqual(0, len(result.errors))
 
618
            self.assertLength(0, total_failures)
618
619
 
619
620
 
620
621
class TestTestCaseWithTransport(tests.TestCaseWithTransport):
621
622
    """Tests for the convenience functions TestCaseWithTransport introduces."""
622
623
 
623
624
    def test_get_readonly_url_none(self):
624
 
        from bzrlib.transport import get_transport
625
625
        from bzrlib.transport.readonly import ReadonlyTransportDecorator
626
626
        self.vfs_transport_factory = memory.MemoryServer
627
627
        self.transport_readonly_server = None
629
629
        # for the server
630
630
        url = self.get_readonly_url()
631
631
        url2 = self.get_readonly_url('foo/bar')
632
 
        t = get_transport(url)
633
 
        t2 = get_transport(url2)
 
632
        t = transport.get_transport(url)
 
633
        t2 = transport.get_transport(url2)
634
634
        self.failUnless(isinstance(t, ReadonlyTransportDecorator))
635
635
        self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
636
636
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
637
637
 
638
638
    def test_get_readonly_url_http(self):
639
639
        from bzrlib.tests.http_server import HttpServer
640
 
        from bzrlib.transport import get_transport
641
640
        from bzrlib.transport.http import HttpTransportBase
642
641
        self.transport_server = test_server.LocalURLServer
643
642
        self.transport_readonly_server = HttpServer
645
644
        url = self.get_readonly_url()
646
645
        url2 = self.get_readonly_url('foo/bar')
647
646
        # the transport returned may be any HttpTransportBase subclass
648
 
        t = get_transport(url)
649
 
        t2 = get_transport(url2)
 
647
        t = transport.get_transport(url)
 
648
        t2 = transport.get_transport(url2)
650
649
        self.failUnless(isinstance(t, HttpTransportBase))
651
650
        self.failUnless(isinstance(t2, HttpTransportBase))
652
651
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
690
689
class TestChrootedTest(tests.ChrootedTestCase):
691
690
 
692
691
    def test_root_is_root(self):
693
 
        from bzrlib.transport import get_transport
694
 
        t = get_transport(self.get_readonly_url())
 
692
        t = transport.get_transport(self.get_readonly_url())
695
693
        url = t.base
696
694
        self.assertEqual(url, t.clone('..').base)
697
695
 
803
801
        self.requireFeature(test_lsprof.LSProfFeature)
804
802
        result_stream = StringIO()
805
803
        result = bzrlib.tests.VerboseTestResult(
806
 
            unittest._WritelnDecorator(result_stream),
 
804
            result_stream,
807
805
            descriptions=0,
808
806
            verbosity=2,
809
807
            )
864
862
        # verbose test output formatting
865
863
        result_stream = StringIO()
866
864
        result = bzrlib.tests.VerboseTestResult(
867
 
            unittest._WritelnDecorator(result_stream),
 
865
            result_stream,
868
866
            descriptions=0,
869
867
            verbosity=2,
870
868
            )
880
878
        output = result_stream.getvalue()[prefix:]
881
879
        lines = output.splitlines()
882
880
        self.assertContainsRe(lines[0], r'XFAIL *\d+ms$')
 
881
        if sys.version_info > (2, 7):
 
882
            self.expectFailure("_ExpectedFailure on 2.7 loses the message",
 
883
                self.assertNotEqual, lines[1], '    ')
883
884
        self.assertEqual(lines[1], '    foo')
884
885
        self.assertEqual(2, len(lines))
885
886
 
919
920
        # verbose test output formatting
920
921
        result_stream = StringIO()
921
922
        result = bzrlib.tests.VerboseTestResult(
922
 
            unittest._WritelnDecorator(result_stream),
 
923
            result_stream,
923
924
            descriptions=0,
924
925
            verbosity=2,
925
926
            )
1421
1422
        sample_test = TestTestCase("method_that_times_a_bit_twice")
1422
1423
        output_stream = StringIO()
1423
1424
        result = bzrlib.tests.VerboseTestResult(
1424
 
            unittest._WritelnDecorator(output_stream),
 
1425
            output_stream,
1425
1426
            descriptions=0,
1426
1427
            verbosity=2)
1427
1428
        sample_test.run(result)
2339
2340
            os.chdir = orig_chdir
2340
2341
        self.assertEqual(['foo', 'current'], chdirs)
2341
2342
 
 
2343
    def test_get_bzr_path_with_cwd_bzrlib(self):
 
2344
        self.get_source_path = lambda: ""
 
2345
        self.overrideAttr(os.path, "isfile", lambda path: True)
 
2346
        self.assertEqual(self.get_bzr_path(), "bzr")
 
2347
 
2342
2348
 
2343
2349
class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport):
2344
2350
    """Tests that really need to do things with an external bzr."""