128
128
def test_get_transport_permutations(self):
129
# this checks that we the module get_test_permutations call
130
# is made by the adapter get_transport_test_permitations method.
129
# this checks that get_test_permutations defined by the module is
130
# called by the adapter get_transport_test_permutations method.
131
131
class MockModule(object):
132
132
def get_test_permutations(self):
133
133
return sample_permutation
139
139
adapter.get_transport_test_permutations(MockModule()))
141
141
def test_adapter_checks_all_modules(self):
142
# this checks that the adapter returns as many permurtations as
143
# there are in all the registered# transport modules for there
144
# - we assume if this matches its probably doing the right thing
145
# especially in combination with the tests for setting the right
142
# this checks that the adapter returns as many permutations as there
143
# are in all the registered transport modules - we assume if this
144
# matches its probably doing the right thing especially in combination
145
# with the tests for setting the right classes below.
147
146
from bzrlib.tests.test_transport_implementations \
148
147
import TransportTestProviderAdapter
149
148
from bzrlib.transport import _get_transport_modules
235
234
adapter.scenarios)
238
class TestRepositoryProviderAdapter(TestCase):
237
class TestRepositoryParameterisation(TestCase):
239
238
"""A group of tests that test the repository implementation test adapter."""
241
def test_constructor(self):
242
# check that constructor parameters are passed through to the
244
from bzrlib.tests.repository_implementations import RepositoryTestProviderAdapter
247
formats = [("c", "C"), ("d", "D")]
248
adapter = RepositoryTestProviderAdapter(server1, server2, formats)
251
{'bzrdir_format': 'C',
252
'repository_format': 'c',
253
'transport_readonly_server': 'b',
254
'transport_server': 'a'}),
256
{'bzrdir_format': 'D',
257
'repository_format': 'd',
258
'transport_readonly_server': 'b',
259
'transport_server': 'a'})],
262
240
def test_setting_vfs_transport(self):
263
241
"""The vfs_transport_factory can be set optionally."""
264
from bzrlib.tests.repository_implementations import RepositoryTestProviderAdapter
265
formats = [("a", "b"), ("c", "d")]
266
adapter = RepositoryTestProviderAdapter(None, None, formats,
242
from bzrlib.tests.repository_implementations import formats_to_scenarios
243
scenarios = formats_to_scenarios(
244
[("a", "b"), ("c", "d")],
267
247
vfs_transport_factory="vfs")
268
248
self.assertEqual([
278
258
'transport_readonly_server': None,
279
259
'transport_server': None,
280
260
'vfs_transport_factory': 'vfs'})],
283
263
def test_formats_to_scenarios(self):
284
264
"""The adapter can generate all the scenarios needed."""
285
from bzrlib.tests.repository_implementations import RepositoryTestProviderAdapter
286
no_vfs_adapter = RepositoryTestProviderAdapter("server", "readonly",
288
vfs_adapter = RepositoryTestProviderAdapter("server", "readonly",
289
[], vfs_transport_factory="vfs")
265
from bzrlib.tests.repository_implementations import formats_to_scenarios
266
formats = [("c", "C"), (1, "D")]
267
no_vfs_scenarios = formats_to_scenarios(formats, "server", "readonly",
269
vfs_scenarios = formats_to_scenarios(formats, "server", "readonly",
270
vfs_transport_factory="vfs")
290
271
# no_vfs generate scenarios without vfs_transport_factor
291
formats = [("c", "C"), (1, "D")]
292
272
self.assertEqual([
294
274
{'bzrdir_format': 'C',
314
294
'transport_readonly_server': 'readonly',
315
295
'transport_server': 'server',
316
296
'vfs_transport_factory': 'vfs'})],
317
vfs_adapter.formats_to_scenarios(formats))
320
300
class TestTestScenarioApplier(TestCase):
995
975
self.assertEqual(None, result._extractBenchmarkTime(test))
978
class TestUnicodeFilenameFeature(TestCase):
980
def test_probe_passes(self):
981
"""UnicodeFilenameFeature._probe passes."""
982
# We can't test much more than that because the behaviour depends
984
tests.UnicodeFilenameFeature._probe()
998
987
class TestRunner(TestCase):
1000
989
def dummy_test(self):
1694
1683
re_filtered = filter_suite_by_re(self.suite, my_pattern)
1695
1684
self.assertEqual(_test_ids(re_filtered), _test_ids(filtered_suite))
1686
def test_condition_id_startswith(self):
1687
klass = 'bzrlib.tests.test_selftest.TestSelftestFiltering.'
1688
start = klass + 'test_condition_id_starts'
1689
test_names = [klass + 'test_condition_id_startswith']
1690
filtered_suite = filter_suite_by_condition(
1691
self.suite, tests.condition_id_startswith(start))
1692
my_pattern = 'TestSelftestFiltering.*test_condition_id_startswith'
1693
re_filtered = filter_suite_by_re(self.suite, my_pattern)
1694
self.assertEqual(_test_ids(re_filtered), _test_ids(filtered_suite))
1697
1696
def test_condition_isinstance(self):
1698
1697
filtered_suite = filter_suite_by_condition(self.suite,
1699
1698
condition_isinstance(self.__class__))
1749
1748
['bzrlib.tests.test_selftest.'
1750
1749
'TestSelftestFiltering.test_filter_suite_by_id_list'])
1751
def test_filter_suite_by_id_startswith(self):
1752
# By design this test may fail if another test is added whose name also
1753
# begins with the start value used.
1754
klass = 'bzrlib.tests.test_selftest.TestSelftestFiltering.'
1755
start = klass + 'test_filter_suite_by_id_starts'
1756
test_list = [klass + 'test_filter_suite_by_id_startswith']
1757
filtered_suite = tests.filter_suite_by_id_startswith(self.suite, start)
1758
filtered_names = _test_ids(filtered_suite)
1761
['bzrlib.tests.test_selftest.'
1762
'TestSelftestFiltering.test_filter_suite_by_id_startswith'])
1752
1764
def test_preserve_input(self):
1753
1765
# NB: Surely this is something in the stdlib to do this?
1754
1766
self.assertTrue(self.suite is preserve_input(self.suite))
2030
2042
suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2031
2043
self.assertEquals([], _test_ids(suite))
2046
class TestFilteredByNameStartTestLoader(tests.TestCase):
2048
def _create_loader(self, name_start):
2049
def needs_module(name):
2050
return name.startswith(name_start) or name_start.startswith(name)
2051
loader = TestUtil.FilteredByModuleTestLoader(needs_module)
2054
def test_load_tests(self):
2055
test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
2056
loader = self._create_loader('bzrlib.tests.test_samp')
2058
suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2059
self.assertEquals(test_list, _test_ids(suite))
2061
def test_load_tests_inside_module(self):
2062
test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
2063
loader = self._create_loader('bzrlib.tests.test_sampler.Demo')
2065
suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2066
self.assertEquals(test_list, _test_ids(suite))
2068
def test_exclude_tests(self):
2069
test_list = ['bogus']
2070
loader = self._create_loader('bogus')
2072
suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2073
self.assertEquals([], _test_ids(suite))