Test Loader¶
nose’s test loader implements the same basic functionality as its superclass, unittest.TestLoader, but extends it by more liberal interpretations of what may be a test and how a test may be named.
- class nose.loader.TestLoader(config=None, importer=None, workingDir=None, selector=None)¶
Test loader that extends unittest.TestLoader to:
Load tests from test-like functions and classes that are not unittest.TestCase subclasses
Find and load test modules in a directory
Support tests that are generators
Support easy extensions of or changes to that behavior through plugins
- getTestCaseNames(testCaseClass)¶
Override to select with selector, unless config.getTestCaseNamesCompat is True
- loadTestsFromDir(path)¶
Load tests from the directory at path. This is a generator – each suite of tests from a module or other file is yielded and is expected to be executed before the next file is examined.
- loadTestsFromFile(filename)¶
Load tests from a non-module file. Default is to raise a ValueError; plugins may implement loadTestsFromFile to provide a list of tests loaded from the file.
- loadTestsFromGenerator(generator, module)¶
Lazy-load tests from a generator function. The generator function may yield either:
a callable, or
a function name resolvable within the same module
- loadTestsFromGeneratorMethod(generator, cls)¶
Lazy-load tests from a generator method.
This is more complicated than loading from a generator function, since a generator method may yield:
a function
a bound or unbound method, or
a method name
- loadTestsFromModule(module, path=None, discovered=False)¶
Load all tests from module and return a suite containing them. If the module has been discovered and is not test-like, the suite will be empty by default, though plugins may add their own tests.
- loadTestsFromName(name, module=None, discovered=False)¶
Load tests from the entity with the given name.
The name may indicate a file, directory, module, or any object within a module. See nose.util.split_test_name for details on test name parsing.
- loadTestsFromNames(names, module=None)¶
Load tests from all names, returning a suite containing all tests.
- loadTestsFromTestCase(testCaseClass)¶
Load tests from a unittest.TestCase subclass.
- loadTestsFromTestClass(cls)¶
Load tests from a test class that is not a unittest.TestCase subclass.
In this case, we can’t depend on the class’s __init__ taking method name arguments, so we have to compose a MethodTestCase for each method in the class that looks testlike.
- parseGeneratedTest(test)¶
Given the yield value of a test generator, return a func and args.
This is used in the two loadTestsFromGenerator* methods.
- resolve(name, module)¶
Resolve name within module
- suiteClass = None¶
- nose.loader.defaultTestLoader¶
alias of
TestLoader