~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
        from bzrlib.bzrdir import BzrDirTestProviderAdapter
194
194
        input_test = TestBzrDirProviderAdapter(
195
195
            "test_adapted_tests")
 
196
        vfs_factory = "v"
196
197
        server1 = "a"
197
198
        server2 = "b"
198
199
        formats = ["c", "d"]
199
 
        adapter = BzrDirTestProviderAdapter(server1, server2, formats)
 
200
        adapter = BzrDirTestProviderAdapter(vfs_factory,
 
201
            server1, server2, formats)
200
202
        suite = adapter.adapt(input_test)
201
203
        tests = list(iter(suite))
202
204
        self.assertEqual(2, len(tests))
203
205
        self.assertEqual(tests[0].bzrdir_format, formats[0])
 
206
        self.assertEqual(tests[0].vfs_transport_factory, vfs_factory)
204
207
        self.assertEqual(tests[0].transport_server, server1)
205
208
        self.assertEqual(tests[0].transport_readonly_server, server2)
206
209
        self.assertEqual(tests[1].bzrdir_format, formats[1])
 
210
        self.assertEqual(tests[1].vfs_transport_factory, vfs_factory)
207
211
        self.assertEqual(tests[1].transport_server, server1)
208
212
        self.assertEqual(tests[1].transport_readonly_server, server2)
209
213
 
233
237
        self.assertEqual(tests[1].transport_server, server1)
234
238
        self.assertEqual(tests[1].transport_readonly_server, server2)
235
239
 
 
240
    def test_setting_vfs_transport(self):
 
241
        """The vfs_transport_factory can be set optionally."""
 
242
        from bzrlib.repository import RepositoryTestProviderAdapter
 
243
        input_test = TestRepositoryProviderAdapter(
 
244
            "test_adapted_tests")
 
245
        formats = [("c", "C")]
 
246
        adapter = RepositoryTestProviderAdapter(None, None, formats,
 
247
            vfs_transport_factory="vfs")
 
248
        suite = adapter.adapt(input_test)
 
249
        tests = list(iter(suite))
 
250
        self.assertEqual(1, len(tests))
 
251
        self.assertEqual(tests[0].vfs_transport_factory, "vfs")
 
252
 
236
253
 
237
254
class TestInterRepositoryProviderAdapter(TestCase):
238
255
    """A group of tests that test the InterRepository test adapter."""
739
756
        result.report_known_failure(test, err)
740
757
        output = result_stream.getvalue()[prefix:]
741
758
        lines = output.splitlines()
742
 
        self.assertEqual(lines, ['XFAIL                   0ms', '    foo'])
743
 
    
 
759
        self.assertContainsRe(lines[0], r'XFAIL *\d+ms$')
 
760
        self.assertEqual(lines[1], '    foo')
 
761
        self.assertEqual(2, len(lines))
 
762
 
744
763
    def test_text_report_known_failure(self):
745
764
        # text test output formatting
746
765
        pb = MockProgress()
933
952
        stream = StringIO()
934
953
        runner = TextTestRunner(stream=stream)
935
954
        result = self.run_test_runner(runner, test)
936
 
        self.assertEqual(
937
 
            '\n'
938
 
            '----------------------------------------------------------------------\n'
939
 
            'Ran 1 test in 0.000s\n'
940
 
            '\n'
941
 
            'OK (known_failures=1)\n',
942
 
            stream.getvalue())
 
955
        self.assertContainsRe(stream.getvalue(),
 
956
            '\n'
 
957
            '-*\n'
 
958
            'Ran 1 test in .*\n'
 
959
            '\n'
 
960
            'OK \\(known_failures=1\\)\n')
943
961
 
944
962
    def test_skipped_test(self):
945
963
        # run a test that is skipped, and check the suite as a whole still