The TestLoader class is used to create test suites from
classes and modules. Normally, there is no need to create an instance
of this class; the unittest module provides an instance
that can be shared as the defaultTestLoader
module attribute.
Using a subclass or instance would allow customization of some
configurable properties.
TestLoader objects have the following methods:
testCaseClass) |
module) |
Warning: While using a hierarchy of Testcase-derived classes can be convenient in sharing fixtures and helper functions, defining test methods on base classes that are not intended to be instantiated directly does not play well with this method. Doing so, however, can be useful when the fixtures are different and defined in subclasses.
name[, module]) |
The specifier name is a ``dotted name'' that may resolve
either to a module, a test case class, a test method within a test
case class, or a callable object which returns a TestCase or
TestSuite instance. For example, if you have a module
SampleTests containing a TestCase-derived class
SampleTestCase with three test methods (test_one(),
test_two(), and test_three()), the specifier
'SampleTests.SampleTestCase'
would cause this method to
return a suite which will run all three test methods. Using the
specifier 'SampleTests.SampleTestCase.test_two'
would cause
it to return a test suite which will run only the
test_two() test method. The specifier can refer to modules
and packages which have not been imported; they will be imported as
a side-effect.
The method optionally resolves name relative to a given module.
names[, module]) |
testCaseClass) |
The following attributes of a TestLoader can be configured either by subclassing or assignment on an instance:
'test'
.
None
to disable
the sort.