/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/bzrdir_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:
24
24
rather than in tests/branch_implementations/*.py.
25
25
"""
26
26
 
27
 
from bzrlib.bzrdir import BzrDirTestProviderAdapter, BzrDirFormat
 
27
from bzrlib.bzrdir import BzrDirFormat
28
28
from bzrlib.tests import (
29
29
                          adapt_modules,
30
30
                          default_transport,
31
31
                          TestCaseWithTransport,
32
32
                          TestLoader,
 
33
                          TestScenarioApplier,
33
34
                          TestSuite,
34
35
                          )
35
36
from bzrlib.transport.memory import MemoryServer
36
37
 
37
38
 
 
39
class BzrDirTestProviderAdapter(TestScenarioApplier):
 
40
    """A tool to generate a suite testing multiple bzrdir formats at once.
 
41
 
 
42
    This is done by copying the test once for each transport and injecting
 
43
    the transport_server, transport_readonly_server, and bzrdir_format
 
44
    classes into each copy. Each copy is also given a new id() to make it
 
45
    easy to identify.
 
46
    """
 
47
 
 
48
    def __init__(self, vfs_factory, transport_server, transport_readonly_server,
 
49
        formats):
 
50
        """Create an object to adapt tests.
 
51
 
 
52
        :param vfs_server: A factory to create a Transport Server which has
 
53
            all the VFS methods working, and is writable.
 
54
        """
 
55
        self._vfs_factory = vfs_factory
 
56
        self._transport_server = transport_server
 
57
        self._transport_readonly_server = transport_readonly_server
 
58
        self.scenarios = self.formats_to_scenarios(formats)
 
59
    
 
60
    def formats_to_scenarios(self, formats):
 
61
        """Transform the input formats to a list of scenarios.
 
62
 
 
63
        :param formats: A list of bzrdir_format objects.
 
64
        """
 
65
        result = []
 
66
        for format in formats:
 
67
            scenario = (format.__class__.__name__, {
 
68
                "vfs_transport_factory":self._vfs_factory,
 
69
                "transport_server":self._transport_server,
 
70
                "transport_readonly_server":self._transport_readonly_server,
 
71
                "bzrdir_format":format,
 
72
                })
 
73
            result.append(scenario)
 
74
        return result
 
75
 
 
76
 
38
77
class TestCaseWithBzrDir(TestCaseWithTransport):
39
78
 
40
79
    def setUp(self):