~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_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:
41
41
                          TestSuite,
42
42
                          )
43
43
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
 
44
from bzrlib.tests.workingtree_implementations import (
 
45
    WorkingTreeTestProviderAdapter,
 
46
    )
44
47
from bzrlib.revisiontree import RevisionTree
45
48
from bzrlib.workingtree import (
46
49
    WorkingTreeFormat,
47
50
    WorkingTreeFormat3,
48
 
    WorkingTreeTestProviderAdapter,
49
51
    _legacy_formats,
50
52
    )
51
53
from bzrlib.workingtree_4 import (
289
291
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
290
292
    """Generate test suites for each Tree implementation in bzrlib.
291
293
 
292
 
    Currently this covers all working tree formats, and RevisionTree by 
293
 
    committing a working tree to create the revision tree.
 
294
    Currently this covers all working tree formats, and RevisionTree and
 
295
    DirStateRevisionTree by committing a working tree to create the revision
 
296
    tree.
294
297
    """
295
298
 
296
 
    def adapt(self, test):
297
 
        result = super(TreeTestProviderAdapter, self).adapt(test)
298
 
        for adapted_test in result:
 
299
    def __init__(self, transport_server, transport_readonly_server, formats):
 
300
        super(TreeTestProviderAdapter, self).__init__(transport_server,
 
301
            transport_readonly_server, formats)
 
302
        # now adjust the scenarios and add the non-working-tree tree scenarios.
 
303
        for scenario in self.scenarios:
299
304
            # for working tree adapted tests, preserve the tree
300
 
            adapted_test.workingtree_to_test_tree = return_parameter
301
 
        # this is the default in that it's used to test the generic InterTree
 
305
            scenario[1]["workingtree_to_test_tree"] = return_parameter
 
306
        # add RevisionTree scenario
 
307
        # this is the 'default format' in that it's used to test the generic InterTree
302
308
        # code.
303
309
        default_format = WorkingTreeFormat3()
304
 
        revision_tree_test = self._clone_test(
305
 
            test,
306
 
            default_format._matchingbzrdir, 
307
 
            default_format,
308
 
            RevisionTree.__name__)
309
 
        revision_tree_test.workingtree_to_test_tree = revision_tree_from_workingtree
310
 
        result.addTest(revision_tree_test)
311
 
        # also explicity test WorkingTree4 against everything
 
310
        self.scenarios.append(self.formats_to_scenarios([
 
311
            (default_format, default_format._matchingbzrdir)])[0])
 
312
        self.scenarios[-1] = (RevisionTree.__name__, self.scenarios[-1][1])
 
313
        self.scenarios[-1][1]["workingtree_to_test_tree"] = revision_tree_from_workingtree
 
314
 
 
315
        # also test WorkingTree4's RevisionTree implementation which is specialised.
312
316
        dirstate_format = WorkingTreeFormat4()
313
 
        dirstate_revision_tree_test = self._clone_test(
314
 
            test,
315
 
            dirstate_format._matchingbzrdir,
316
 
            dirstate_format,
317
 
            DirStateRevisionTree.__name__)
318
 
        dirstate_revision_tree_test.workingtree_to_test_tree = _dirstate_tree_from_workingtree
319
 
        result.addTest(dirstate_revision_tree_test)
320
 
        return result
 
317
        self.scenarios.append(self.formats_to_scenarios([
 
318
            (dirstate_format, dirstate_format._matchingbzrdir)])[0])
 
319
        self.scenarios[-1] = (DirStateRevisionTree.__name__, self.scenarios[-1][1])
 
320
        self.scenarios[-1][1]["workingtree_to_test_tree"] = _dirstate_tree_from_workingtree
321
321
 
322
322
 
323
323
def test_suite():