20
20
from bzrlib.lazy_import import lazy_import
21
21
lazy_import(globals(), """
22
from copy import deepcopy
23
from unittest import TestSuite
24
22
from warnings import warn
2099
2097
return BasicTags(self)
2102
class BranchTestProviderAdapter(object):
2103
"""A tool to generate a suite testing multiple branch formats at once.
2105
This is done by copying the test once for each transport and injecting
2106
the transport_server, transport_readonly_server, and branch_format
2107
classes into each copy. Each copy is also given a new id() to make it
2111
def __init__(self, transport_server, transport_readonly_server, formats,
2112
vfs_transport_factory=None):
2113
self._transport_server = transport_server
2114
self._transport_readonly_server = transport_readonly_server
2115
self._formats = formats
2117
def adapt(self, test):
2118
result = TestSuite()
2119
for branch_format, bzrdir_format in self._formats:
2120
new_test = deepcopy(test)
2121
new_test.transport_server = self._transport_server
2122
new_test.transport_readonly_server = self._transport_readonly_server
2123
new_test.bzrdir_format = bzrdir_format
2124
new_test.branch_format = branch_format
2125
def make_new_test_id():
2126
# the format can be either a class or an instance
2127
name = getattr(branch_format, '__name__',
2128
branch_format.__class__.__name__)
2129
new_id = "%s(%s)" % (new_test.id(), name)
2130
return lambda: new_id
2131
new_test.id = make_new_test_id()
2132
result.addTest(new_test)
2136
2100
######################################################################
2137
2101
# results of operations