2384
2384
suite = TestUtil.TestSuite()
2385
2385
loader = TestUtil.TestLoader()
2386
2386
suite.addTest(loader.loadTestsFromModuleNames(testmod_names))
2387
from bzrlib.transport import TransportTestProviderAdapter
2387
from bzrlib.tests.test_transport_implementations import TransportTestProviderAdapter
2388
2388
adapter = TransportTestProviderAdapter()
2389
2389
adapt_modules(test_transport_implementations, adapter, loader, suite)
2390
2390
for package in packages_to_test():
2489
2489
if getattr(self, 'feature_name', None):
2490
2490
return self.feature_name()
2491
2491
return self.__class__.__name__
2494
class TestScenarioApplier(object):
2495
"""A tool to apply scenarios to tests."""
2497
def adapt(self, test):
2498
"""Return a TestSuite containing a copy of test for each scenario."""
2499
result = unittest.TestSuite()
2500
for scenario in self.scenarios:
2501
result.addTest(self.adapt_test_to_scenario(test, scenario))
2504
def adapt_test_to_scenario(self, test, scenario):
2505
"""Copy test and apply scenario to it.
2507
:param test: A test to adapt.
2508
:param scenario: A tuple describing the scenarion.
2509
The first element of the tuple is the new test id.
2510
The second element is a dict containing attributes to set on the
2512
:return: The adapted test.
2514
from copy import deepcopy
2515
new_test = deepcopy(test)
2516
for name, value in scenario[1].items():
2517
setattr(new_test, name, value)
2518
new_id = "%s(%s)" % (new_test.id(), scenario[0])
2519
new_test.id = lambda: new_id