/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_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:
28
28
                          adapt_modules,
29
29
                          default_transport,
30
30
                          TestLoader,
 
31
                          TestScenarioApplier,
31
32
                          TestSuite,
32
33
                          )
33
34
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
34
35
from bzrlib.workingtree import (WorkingTreeFormat,
35
 
                                WorkingTreeTestProviderAdapter,
36
36
                                _legacy_formats,
37
37
                                )
38
38
 
39
39
 
 
40
class WorkingTreeTestProviderAdapter(TestScenarioApplier):
 
41
    """A tool to generate a suite testing multiple workingtree formats at once.
 
42
 
 
43
    This is done by copying the test once for each transport and injecting
 
44
    the transport_server, transport_readonly_server, and workingtree_format
 
45
    classes into each copy. Each copy is also given a new id() to make it
 
46
    easy to identify.
 
47
    """
 
48
 
 
49
    def __init__(self, transport_server, transport_readonly_server, formats):
 
50
        self._transport_server = transport_server
 
51
        self._transport_readonly_server = transport_readonly_server
 
52
        self.scenarios = self.formats_to_scenarios(formats)
 
53
    
 
54
    def formats_to_scenarios(self, formats):
 
55
        """Transform the input formats to a list of scenarios.
 
56
 
 
57
        :param formats: A list of (workingtree_format, bzrdir_format).
 
58
        """
 
59
    
 
60
        result = []
 
61
        for workingtree_format, bzrdir_format in formats:
 
62
            scenario = (workingtree_format.__class__.__name__, {
 
63
                "transport_server":self._transport_server,
 
64
                "transport_readonly_server":self._transport_readonly_server,
 
65
                "bzrdir_format":bzrdir_format,
 
66
                "workingtree_format":workingtree_format,
 
67
                })
 
68
            result.append(scenario)
 
69
        return result
 
70
 
 
71
 
40
72
class TestCaseWithWorkingTree(TestCaseWithBzrDir):
41
73
 
42
74
    def make_branch_and_tree(self, relpath, format=None):