~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/__init__.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    TestCaseWithTree,
37
37
    )
38
38
from bzrlib.tree import InterTree
39
 
from bzrlib.workingtree import (WorkingTreeFormat,
40
 
                                WorkingTreeTestProviderAdapter,
41
 
                                )
 
39
from bzrlib.workingtree import (
 
40
    WorkingTreeFormat3,
 
41
    WorkingTreeTestProviderAdapter,
 
42
    )
 
43
 
 
44
 
 
45
def return_provided_trees(source, target):
 
46
    """Return the source and target tree unaltered."""
 
47
    return source, target
42
48
 
43
49
 
44
50
class TestCaseWithTwoTrees(TestCaseWithTree):
51
57
        made_control.create_branch()
52
58
        return self.workingtree_format_to.initialize(made_control)
53
59
 
54
 
    def get_to_tree_no_parents_no_content(self, empty_tree):
55
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_no_content(empty_tree, converter=self.workingtree_to_test_tree_to)
56
 
 
57
 
    def get_to_tree_no_parents_abc_content(self, empty_tree):
58
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content(empty_tree, converter=self.workingtree_to_test_tree_to)
59
 
 
60
 
    def get_to_tree_no_parents_abc_content_2(self, empty_tree):
61
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_2(empty_tree, converter=self.workingtree_to_test_tree_to)
62
 
 
63
 
    def get_to_tree_no_parents_abc_content_3(self, empty_tree):
64
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_3(empty_tree, converter=self.workingtree_to_test_tree_to)
65
 
 
66
 
    def get_to_tree_no_parents_abc_content_4(self, empty_tree):
67
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_4(empty_tree, converter=self.workingtree_to_test_tree_to)
68
 
 
69
 
    def get_to_tree_no_parents_abc_content_5(self, empty_tree):
70
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_5(empty_tree, converter=self.workingtree_to_test_tree_to)
71
 
 
72
 
    def get_to_tree_no_parents_abc_content_6(self, empty_tree):
73
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_6(empty_tree, converter=self.workingtree_to_test_tree_to)
74
 
 
75
60
 
76
61
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
77
62
    """Generate test suites for each InterTree implementation in bzrlib."""
80
65
        result = TestSuite()
81
66
        for (intertree_class,
82
67
            workingtree_format,
83
 
            workingtree_to_test_tree,
84
68
            workingtree_format_to,
85
 
            workingtree_to_test_tree_to) in self._formats:
 
69
            mutable_trees_to_test_trees) in self._formats:
86
70
            new_test = self._clone_test(
87
71
                test,
88
72
                workingtree_format._matchingbzrdir,
89
73
                workingtree_format,
90
74
                intertree_class.__name__)
91
75
            new_test.intertree_class = intertree_class
92
 
            new_test.workingtree_to_test_tree = workingtree_to_test_tree
93
76
            new_test.workingtree_format_to = workingtree_format_to
94
 
            new_test.workingtree_to_test_tree_to = workingtree_to_test_tree_to
 
77
            # mutable_trees_to_test_trees takes two trees and converts them to
 
78
            # whatever relationship the optimiser under test requires.
 
79
            new_test.mutable_trees_to_test_trees = mutable_trees_to_test_trees
 
80
            # workingtree_to_test_tree is set to disable changing individual
 
81
            # trees: instead the mutable_trees_to_test_trees helper is used.
 
82
            new_test.workingtree_to_test_tree = return_parameter
95
83
            result.addTest(new_test)
96
84
        return result
97
85
 
102
90
    # load the tests of the infrastructure for these tests
103
91
    result.addTests(loader.loadTestsFromModuleNames(['bzrlib.tests.intertree_implementations']))
104
92
 
105
 
    default_tree_format = WorkingTreeFormat.get_default_format()
 
93
    default_tree_format = WorkingTreeFormat3()
106
94
    test_intertree_implementations = [
107
95
        'bzrlib.tests.intertree_implementations.test_compare',
108
96
        ]
109
97
    test_intertree_permutations = [
110
98
        # test InterTree with two default-format working trees.
111
 
        (InterTree, default_tree_format, return_parameter,
112
 
         default_tree_format, return_parameter)]
 
99
        (InterTree, default_tree_format, default_tree_format,
 
100
         return_provided_trees)]
113
101
    for optimiser in InterTree._optimisers:
114
102
        test_intertree_permutations.append(
115
103
            (optimiser,
116
 
             optimiser._matching_from_tree_format, optimiser._from_tree_converter,
117
 
             optimiser._matching_to_tree_format, optimiser._to_tree_converter))
 
104
             optimiser._matching_from_tree_format,
 
105
             optimiser._matching_to_tree_format,
 
106
             optimiser._test_mutable_trees_to_test_trees))
118
107
    adapter = InterTreeTestProviderAdapter(
119
108
        default_transport,
120
109
        # None here will cause a readonly decorator to be created