~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Andrew Bennetts
  • Date: 2010-09-13 06:36:59 UTC
  • mfrom: (5050.17.16 2.2)
  • mto: This revision was merged to the branch mainline in revision 5419.
  • Revision ID: andrew.bennetts@canonical.com-20100913063659-gs1d1xnsdbj59sx6
Merge lp:bzr/2.2, including fixes for #619872, #631350, #633745.

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"
801
814
        self.requireFeature(test_lsprof.LSProfFeature)
802
815
        result_stream = StringIO()
803
816
        result = bzrlib.tests.VerboseTestResult(
804
 
            unittest._WritelnDecorator(result_stream),
 
817
            result_stream,
805
818
            descriptions=0,
806
819
            verbosity=2,
807
820
            )
862
875
        # verbose test output formatting
863
876
        result_stream = StringIO()
864
877
        result = bzrlib.tests.VerboseTestResult(
865
 
            unittest._WritelnDecorator(result_stream),
 
878
            result_stream,
866
879
            descriptions=0,
867
880
            verbosity=2,
868
881
            )
878
891
        output = result_stream.getvalue()[prefix:]
879
892
        lines = output.splitlines()
880
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], '    ')
881
897
        self.assertEqual(lines[1], '    foo')
882
898
        self.assertEqual(2, len(lines))
883
899
 
917
933
        # verbose test output formatting
918
934
        result_stream = StringIO()
919
935
        result = bzrlib.tests.VerboseTestResult(
920
 
            unittest._WritelnDecorator(result_stream),
 
936
            result_stream,
921
937
            descriptions=0,
922
938
            verbosity=2,
923
939
            )
1419
1435
        sample_test = TestTestCase("method_that_times_a_bit_twice")
1420
1436
        output_stream = StringIO()
1421
1437
        result = bzrlib.tests.VerboseTestResult(
1422
 
            unittest._WritelnDecorator(output_stream),
 
1438
            output_stream,
1423
1439
            descriptions=0,
1424
1440
            verbosity=2)
1425
1441
        sample_test.run(result)
2337
2353
            os.chdir = orig_chdir
2338
2354
        self.assertEqual(['foo', 'current'], chdirs)
2339
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
 
2340
2361
 
2341
2362
class TestActuallyStartBzrSubprocess(tests.TestCaseWithTransport):
2342
2363
    """Tests that really need to do things with an external bzr."""