~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

New test loader reducing modules imports and tests loaded.

* bzrlib/tests/test_selftest.py:
(TestFilteredByModuleTestLoader): Tests for a loader that don't
import unneeded modules.
* bzrlib/tests/TestUtil.py:
(FilteredByModuleTestLoader): Specialized loader importing and
loading tests for a reduced set of modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2034
2034
        self.assertEquals('bar baz', tlist[3])
2035
2035
 
2036
2036
 
 
2037
class TestFilteredByModuleTestLoader(tests.TestCase):
 
2038
 
 
2039
    def _create_loader(self, test_list):
 
2040
        id_filter = tests.TestIdList(test_list)
 
2041
        loader = TestUtil.FilteredByModuleTestLoader(
 
2042
            id_filter.is_module_name_used)
 
2043
        return loader
 
2044
 
 
2045
    def test_load_tests(self):
 
2046
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
 
2047
        loader = self._create_loader(test_list)
 
2048
 
 
2049
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
 
2050
        self.assertEquals(test_list, _test_ids(suite))
 
2051
 
 
2052
    def test_exclude_tests(self):
 
2053
        test_list = ['bogus']
 
2054
        loader = self._create_loader(test_list)
 
2055
 
 
2056
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
 
2057
        self.assertEquals([], _test_ids(suite))