/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 breezy/tests/TestUtil.py

  • Committer: Martin
  • Date: 2017-05-23 14:08:03 UTC
  • mto: (6625.4.6 integration-bisect)
  • mto: This revision was merged to the branch mainline in revision 6629.
  • Revision ID: gzlist@googlemail.com-20170523140803-1bayist4qbqgvku8
Drop custom load_tests implementation and use unittest signature

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        result.addTests(self.loadTestsFromModule(module))
156
156
        return result
157
157
 
158
 
    def loadTestsFromModule(self, module):
159
 
        """Load tests from a module object.
160
 
 
161
 
        This extension of the python test loader looks for an attribute
162
 
        load_tests in the module object, and if not found falls back to the
163
 
        regular python loadTestsFromModule.
164
 
 
165
 
        If a load_tests attribute is found, it is called and the result is
166
 
        returned.
167
 
 
168
 
        load_tests should be defined like so:
169
 
        >>> def load_tests(standard_tests, module, loader):
170
 
        >>>    pass
171
 
 
172
 
        standard_tests is the tests found by the stock TestLoader in the
173
 
        module, module and loader are the module and loader instances.
174
 
 
175
 
        For instance, to run every test twice, you might do:
176
 
        >>> def load_tests(standard_tests, module, loader):
177
 
        >>>     result = loader.suiteClass()
178
 
        >>>     for test in iter_suite_tests(standard_tests):
179
 
        >>>         result.addTests([test, test])
180
 
        >>>     return result
181
 
        """
182
 
        # GZ 2010-07-19: Python 2.7 unittest also uses load_tests but with
183
 
        #                a different and incompatible signature
184
 
        basic_tests = super(TestLoader, self).loadTestsFromModule(module,
185
 
            use_load_tests=False)
186
 
        load_tests = getattr(module, "load_tests", None)
187
 
        if load_tests is not None:
188
 
            return load_tests(basic_tests, module, self)
189
 
        else:
190
 
            return basic_tests
191
 
 
192
158
    def getTestCaseNames(self, test_case_class):
193
159
        test_fn_names = self.test_func_names.get(test_case_class, None)
194
160
        if test_fn_names is not None: