Test Selection

Test selection is handled by a Selector. The test loader calls the appropriate selector method for each object it encounters that it thinks may be a test.

class nose.selector.Selector(config)

Core test selector. Examines test candidates and determines whether, given the specified configuration, the test candidate should be selected as a test.


Does the name match my requirements?

To match, a name must match config.testMatch OR config.include and it must not match config.exclude


Is the class a wanted test class?

A class must be a unittest.TestCase subclass, or match test name requirements. Classes that start with _ are always excluded.


Is the directory a wanted test directory?

All package directories match, so long as they do not match exclude. All other directories must match test requirements.


Is the file a wanted test file?

The file must be a python source file and match testMatch or include, and not match exclude. Files that match ignore are never wanted, regardless of plugin, testMatch, include or exclude settings.


Is the function a test function?


Is the method a test method?


Is the module a test module?

The tail of the module name must match test requirements. One exception: we always want __main__.


alias of Selector

class nose.selector.TestAddress(name, workingDir=None)

A test address represents a user’s request to run a particular test. The user may specify a filename or module (or neither), and/or a callable (a class, function, or method). The naming format for test addresses is:


Filenames that are not absolute will be made absolute relative to the working dir.

The filename or module part will be considered a module name if it doesn’t look like a file, that is, if it doesn’t exist on the file system and it doesn’t contain any directory separators and it doesn’t end in .py.

Callables may be a class name, function name, method name, or class.method specification.