~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Robert Collins
  • Date: 2010-06-28 02:41:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5324.
  • Revision ID: robertc@robertcollins.net-20100628024122-g951fzp74f3u6wst
Sanity check that new_trace_file in pop_log_file is valid, and also fix a test that monkey patched get_terminal_encoding.

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_controldir import make_scenarios
 
211
        from bzrlib.tests.per_bzrdir import make_scenarios
212
212
        vfs_factory = "v"
213
213
        server1 = "a"
214
214
        server2 = "b"
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
625
626
        from bzrlib.transport.readonly import ReadonlyTransportDecorator
626
627
        self.vfs_transport_factory = memory.MemoryServer
627
628
        self.transport_readonly_server = None
629
630
        # for the server
630
631
        url = self.get_readonly_url()
631
632
        url2 = self.get_readonly_url('foo/bar')
632
 
        t = transport.get_transport(url)
633
 
        t2 = transport.get_transport(url2)
 
633
        t = get_transport(url)
 
634
        t2 = get_transport(url2)
634
635
        self.failUnless(isinstance(t, ReadonlyTransportDecorator))
635
636
        self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
636
637
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
637
638
 
638
639
    def test_get_readonly_url_http(self):
639
640
        from bzrlib.tests.http_server import HttpServer
 
641
        from bzrlib.transport import get_transport
640
642
        from bzrlib.transport.http import HttpTransportBase
641
643
        self.transport_server = test_server.LocalURLServer
642
644
        self.transport_readonly_server = HttpServer
644
646
        url = self.get_readonly_url()
645
647
        url2 = self.get_readonly_url('foo/bar')
646
648
        # the transport returned may be any HttpTransportBase subclass
647
 
        t = transport.get_transport(url)
648
 
        t2 = transport.get_transport(url2)
 
649
        t = get_transport(url)
 
650
        t2 = get_transport(url2)
649
651
        self.failUnless(isinstance(t, HttpTransportBase))
650
652
        self.failUnless(isinstance(t2, HttpTransportBase))
651
653
        self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
689
691
class TestChrootedTest(tests.ChrootedTestCase):
690
692
 
691
693
    def test_root_is_root(self):
692
 
        t = transport.get_transport(self.get_readonly_url())
 
694
        from bzrlib.transport import get_transport
 
695
        t = get_transport(self.get_readonly_url())
693
696
        url = t.base
694
697
        self.assertEqual(url, t.clone('..').base)
695
698
 
801
804
        self.requireFeature(test_lsprof.LSProfFeature)
802
805
        result_stream = StringIO()
803
806
        result = bzrlib.tests.VerboseTestResult(
804
 
            result_stream,
 
807
            unittest._WritelnDecorator(result_stream),
805
808
            descriptions=0,
806
809
            verbosity=2,
807
810
            )
862
865
        # verbose test output formatting
863
866
        result_stream = StringIO()
864
867
        result = bzrlib.tests.VerboseTestResult(
865
 
            result_stream,
 
868
            unittest._WritelnDecorator(result_stream),
866
869
            descriptions=0,
867
870
            verbosity=2,
868
871
            )
878
881
        output = result_stream.getvalue()[prefix:]
879
882
        lines = output.splitlines()
880
883
        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], '    ')
884
884
        self.assertEqual(lines[1], '    foo')
885
885
        self.assertEqual(2, len(lines))
886
886
 
920
920
        # verbose test output formatting
921
921
        result_stream = StringIO()
922
922
        result = bzrlib.tests.VerboseTestResult(
923
 
            result_stream,
 
923
            unittest._WritelnDecorator(result_stream),
924
924
            descriptions=0,
925
925
            verbosity=2,
926
926
            )
1422
1422
        sample_test = TestTestCase("method_that_times_a_bit_twice")
1423
1423
        output_stream = StringIO()
1424
1424
        result = bzrlib.tests.VerboseTestResult(
1425
 
            output_stream,
 
1425
            unittest._WritelnDecorator(output_stream),
1426
1426
            descriptions=0,
1427
1427
            verbosity=2)
1428
1428
        sample_test.run(result)
2340
2340
            os.chdir = orig_chdir
2341
2341
        self.assertEqual(['foo', 'current'], chdirs)
2342
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
 
 
2348
2343
 
2349
2344
class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport):
2350
2345
    """Tests that really need to do things with an external bzr."""