~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

(robertc) Introduce Tree interface implementation tests. This corrects behaviour differences in Tree implementations for the __iter__ interface which were revealed by the new tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
        self.assertEqual(tests[1].transport_readonly_server, server2)
325
325
 
326
326
 
 
327
class TestTreeProviderAdapter(TestCase):
 
328
    """Test the setup of tree_implementation tests."""
 
329
 
 
330
    def test_adapted_tests(self):
 
331
        # the tree implementation adapter is meant to setup one instance for
 
332
        # each working tree format, and one additional instance that will
 
333
        # use the default wt format, but create a revision tree for the tests.
 
334
        # this means that the wt ones should have the workingtree_to_test_tree
 
335
        # attribute set to 'return_parameter' and the revision one set to
 
336
        # revision_tree_from_workingtree.
 
337
 
 
338
        from bzrlib.tests.tree_implementations import (
 
339
            TreeTestProviderAdapter,
 
340
            return_parameter,
 
341
            revision_tree_from_workingtree
 
342
            )
 
343
        from bzrlib.workingtree import WorkingTreeFormat
 
344
        input_test = TestTreeProviderAdapter(
 
345
            "test_adapted_tests")
 
346
        server1 = "a"
 
347
        server2 = "b"
 
348
        formats = [("c", "C"), ("d", "D")]
 
349
        adapter = TreeTestProviderAdapter(server1, server2, formats)
 
350
        suite = adapter.adapt(input_test)
 
351
        tests = list(iter(suite))
 
352
        self.assertEqual(3, len(tests))
 
353
        default_format = WorkingTreeFormat.get_default_format()
 
354
        self.assertEqual(tests[0].workingtree_format, formats[0][0])
 
355
        self.assertEqual(tests[0].bzrdir_format, formats[0][1])
 
356
        self.assertEqual(tests[0].transport_server, server1)
 
357
        self.assertEqual(tests[0].transport_readonly_server, server2)
 
358
        self.assertEqual(tests[0].workingtree_to_test_tree, return_parameter)
 
359
        self.assertEqual(tests[1].workingtree_format, formats[1][0])
 
360
        self.assertEqual(tests[1].bzrdir_format, formats[1][1])
 
361
        self.assertEqual(tests[1].transport_server, server1)
 
362
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
363
        self.assertEqual(tests[1].workingtree_to_test_tree, return_parameter)
 
364
        self.assertEqual(tests[2].workingtree_format, default_format)
 
365
        self.assertEqual(tests[2].bzrdir_format, default_format._matchingbzrdir)
 
366
        self.assertEqual(tests[2].transport_server, server1)
 
367
        self.assertEqual(tests[2].transport_readonly_server, server2)
 
368
        self.assertEqual(tests[2].workingtree_to_test_tree,
 
369
            revision_tree_from_workingtree)
 
370
 
 
371
 
327
372
class TestTestCaseWithTransport(TestCaseWithTransport):
328
373
    """Tests for the convenience functions TestCaseWithTransport introduces."""
329
374