45
46
from bzrlib.osutils import getcwd
46
47
from bzrlib.smart import medium
47
48
from bzrlib.symbol_versioning import zero_eleven
48
from bzrlib.tests import TestCaseInTempDir, TestSkipped
49
from bzrlib.tests import TestCaseInTempDir, TestScenarioApplier, TestSkipped
49
50
from bzrlib.tests.test_transport import TestTransportImplementation
50
from bzrlib.transport import memory, remote
51
from bzrlib.transport import memory, remote, _get_transport_modules
51
52
import bzrlib.transport
55
class TransportTestProviderAdapter(TestScenarioApplier):
56
"""A tool to generate a suite testing all transports for a single test.
58
This is done by copying the test once for each transport and injecting
59
the transport_class and transport_server classes into each copy. Each copy
60
is also given a new id() to make it easy to identify.
64
self.scenarios = self._test_permutations()
66
def get_transport_test_permutations(self, module):
67
"""Get the permutations module wants to have tested."""
68
if getattr(module, 'get_test_permutations', None) is None:
69
raise AssertionError("transport module %s doesn't provide get_test_permutations()"
71
##warning("transport module %s doesn't provide get_test_permutations()"
74
return module.get_test_permutations()
76
def _test_permutations(self):
77
"""Return a list of the klass, server_factory pairs to test."""
79
for module in _get_transport_modules():
81
permutations = self.get_transport_test_permutations(
82
reduce(getattr, (module).split('.')[1:], __import__(module)))
83
for (klass, server_factory) in permutations:
84
scenario = (server_factory.__name__,
85
{"transport_class":klass,
86
"transport_server":server_factory})
87
result.append(scenario)
88
except errors.DependencyNotPresent, e:
89
# Continue even if a dependency prevents us
90
# from running this test
54
96
class TransportTests(TestTransportImplementation):