/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

  • Committer: Martin Albisetti
  • Date: 2008-04-08 22:51:37 UTC
  • mfrom: (3346 +trunk)
  • mto: (3350.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 3351.
  • Revision ID: argentina@gmail.com-20080408225137-uynl9dxtsdpi8nl9
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        self.test_func_names[test_case_class] = test_fn_names
142
142
        return test_fn_names
143
143
 
 
144
 
 
145
class FilteredByModuleTestLoader(TestLoader):
 
146
    """A test loader that import only the needed modules."""
 
147
 
 
148
    def __init__(self, needs_module):
 
149
        """Constructor.
 
150
 
 
151
        :param needs_module: a callable taking a module name as a
 
152
            parameter returing True if the module should be loaded.
 
153
        """
 
154
        TestLoader.__init__(self)
 
155
        self.needs_module = needs_module
 
156
 
 
157
    def loadTestsFromModuleName(self, name):
 
158
        if self.needs_module(name):
 
159
            return TestLoader.loadTestsFromModuleName(self, name)
 
160
        else:
 
161
            return self.suiteClass()
 
162
 
 
163
 
144
164
def _load_module_by_name(mod_name):
145
165
    parts = mod_name.split('.')
146
166
    module = __import__(mod_name)