31
31
from bzrlib.branch import (BranchFormat,
32
BranchTestProviderAdapter,
35
34
from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
41
40
from bzrlib.transport.memory import MemoryServer
43
class BranchTestProviderAdapter(tests.TestScenarioApplier):
44
"""A tool to generate a suite testing multiple branch formats at once.
46
This is done by copying the test once for each transport and injecting
47
the transport_server, transport_readonly_server, and branch_format
48
classes into each copy. Each copy is also given a new id() to make it
52
def __init__(self, transport_server, transport_readonly_server, formats,
53
vfs_transport_factory=None):
54
self._transport_server = transport_server
55
self._transport_readonly_server = transport_readonly_server
56
self.scenarios = self.formats_to_scenarios(formats)
58
def formats_to_scenarios(self, formats):
59
"""Transform the input formats to a list of scenarios.
61
:param formats: A list of (branch_format, bzrdir_format).
64
for branch_format, bzrdir_format in formats:
65
# some branches don't have separate format objects.
66
# so we have a conditional here to handle them.
67
scenario_name = getattr(branch_format, '__name__',
68
branch_format.__class__.__name__)
69
scenario = (scenario_name, {
70
"transport_server":self._transport_server,
71
"transport_readonly_server":self._transport_readonly_server,
72
"bzrdir_format":bzrdir_format,
73
"branch_format":branch_format,
75
result.append(scenario)
44
79
class TestCaseWithBranch(TestCaseWithBzrDir):
45
80
"""This helper will be adapted for each branch_implementation test."""