2810
2796
'bzrlib.tests.test_transport_implementations',
2811
2797
'bzrlib.tests.test_read_bundle',
2813
suite = TestUtil.TestSuite()
2814
2799
loader = TestUtil.TestLoader()
2816
if keep_only is not None:
2801
if keep_only is None:
2802
loader = TestUtil.TestLoader()
2817
2804
id_filter = TestIdList(keep_only)
2805
loader = TestUtil.FilteredByModuleTestLoader(id_filter.refers_to)
2806
suite = loader.suiteClass()
2819
2808
# modules building their suite with loadTestsFromModuleNames
2820
if keep_only is None:
2821
suite.addTest(loader.loadTestsFromModuleNames(testmod_names))
2823
for mod in [m for m in testmod_names
2824
if id_filter.is_module_name_used(m)]:
2825
mod_suite = loader.loadTestsFromModuleNames([mod])
2826
mod_suite = filter_suite_by_id_list(mod_suite, id_filter)
2827
suite.addTest(mod_suite)
2809
suite.addTest(loader.loadTestsFromModuleNames(testmod_names))
2829
2811
# modules adapted for transport implementations
2830
2812
from bzrlib.tests.test_transport_implementations import TransportTestProviderAdapter
2831
2813
adapter = TransportTestProviderAdapter()
2832
if keep_only is None:
2833
adapt_modules(test_transport_implementations, adapter, loader, suite)
2835
for mod in [m for m in test_transport_implementations
2836
if id_filter.is_module_name_used(m)]:
2837
mod_suite = TestUtil.TestSuite()
2838
adapt_modules([mod], adapter, loader, mod_suite)
2839
mod_suite = filter_suite_by_id_list(mod_suite, id_filter)
2840
suite.addTest(mod_suite)
2814
adapt_modules(test_transport_implementations, adapter, loader, suite)
2842
2816
# modules defining their own test_suite()
2843
2817
for package in [p for p in packages_to_test()
2844
2818
if (keep_only is None
2845
or id_filter.is_module_name_used(p.__name__))]:
2819
or id_filter.refers_to(p.__name__))]:
2846
2820
pack_suite = package.test_suite()
2847
if keep_only is not None:
2848
pack_suite = filter_suite_by_id_list(pack_suite, id_filter)
2849
2821
suite.addTest(pack_suite)
2851
for mod in MODULES_TO_DOCTEST:
2823
modules_to_doctest = [
2828
'bzrlib.iterablefile',
2835
'bzrlib.version_info_formats.format_custom',
2838
for mod in modules_to_doctest:
2839
if not (keep_only is None or id_filter.refers_to(mod)):
2840
# No tests to keep here, move along
2853
2843
doc_suite = doctest.DocTestSuite(mod)
2854
2844
except ValueError, e:
2855
2845
print '**failed to get doctest for: %s\n%s' % (mod, e)
2857
if keep_only is not None:
2858
# DocTests may use ids which doesn't contain the module name
2859
doc_suite = filter_suite_by_id_list(doc_suite, id_filter)
2860
2847
suite.addTest(doc_suite)
2862
2849
default_encoding = sys.getdefaultencoding()
2863
2850
for name, plugin in bzrlib.plugin.plugins().items():
2864
2851
if keep_only is not None:
2865
if not id_filter.is_module_name_used(plugin.module.__name__):
2852
if not id_filter.refers_to(plugin.module.__name__):
2867
2854
plugin_suite = plugin.test_suite()
2868
2855
# We used to catch ImportError here and turn it into just a warning,
2869
2856
# but really if you don't have --no-plugins this should be a failure.
2870
2857
# mbp 20080213 - see http://bugs.launchpad.net/bugs/189771
2858
if plugin_suite is None:
2859
plugin_suite = plugin.load_plugin_tests(loader)
2871
2860
if plugin_suite is not None:
2872
if keep_only is not None:
2873
plugin_suite = filter_suite_by_id_list(plugin_suite,
2875
2861
suite.addTest(plugin_suite)
2876
2862
if default_encoding != sys.getdefaultencoding():
2877
2863
bzrlib.trace.warning(