~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-02 07:06:39 UTC
  • mfrom: (2553.2.14 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070702070639-um9oyfoc2i6g8umv
(robertc) Reduce duplication in interface based testing by extracting a new class TestScenarioApplier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    revision_tree_from_workingtree,
36
36
    TestCaseWithTree,
37
37
    )
 
38
from bzrlib.tests.workingtree_implementations import (
 
39
    WorkingTreeTestProviderAdapter,
 
40
    )
38
41
from bzrlib.tree import InterTree
39
42
from bzrlib.workingtree import (
40
43
    WorkingTreeFormat3,
41
 
    WorkingTreeTestProviderAdapter,
42
44
    )
43
45
 
44
46
 
61
63
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
62
64
    """Generate test suites for each InterTree implementation in bzrlib."""
63
65
 
64
 
    def adapt(self, test):
65
 
        result = TestSuite()
 
66
    def formats_to_scenarios(self, formats):
 
67
        """Transform the input formats to a list of scenarios.
 
68
 
 
69
        :param formats: A list of tuples:.
 
70
            (intertree_class,
 
71
             workingtree_format,
 
72
             workingtree_format_to,
 
73
             mutable_trees_to_test_trees)
 
74
        """
 
75
        result = []
66
76
        for (intertree_class,
67
77
            workingtree_format,
68
78
            workingtree_format_to,
69
 
            mutable_trees_to_test_trees) in self._formats:
70
 
            new_test = self._clone_test(
71
 
                test,
72
 
                workingtree_format._matchingbzrdir,
73
 
                workingtree_format,
74
 
                intertree_class.__name__)
75
 
            new_test.intertree_class = intertree_class
76
 
            new_test.workingtree_format_to = workingtree_format_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
83
 
            result.addTest(new_test)
 
79
            mutable_trees_to_test_trees) in formats:
 
80
            scenario = (intertree_class.__name__, {
 
81
                "transport_server":self._transport_server,
 
82
                "transport_readonly_server":self._transport_readonly_server,
 
83
                "bzrdir_format":workingtree_format._matchingbzrdir,
 
84
                "workingtree_format":workingtree_format,
 
85
                "intertree_class":intertree_class,
 
86
                "workingtree_format_to":workingtree_format_to,
 
87
                # mutable_trees_to_test_trees takes two trees and converts them to,
 
88
                # whatever relationship the optimiser under test requires.,
 
89
                "mutable_trees_to_test_trees":mutable_trees_to_test_trees,
 
90
                # workingtree_to_test_tree is set to disable changing individual,
 
91
                # trees: instead the mutable_trees_to_test_trees helper is used.,
 
92
                "workingtree_to_test_tree":return_parameter,
 
93
                })
 
94
            result.append(scenario)
84
95
        return result
85
96
 
86
97