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.

matches(name)

Does the name match my requirements?

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

wantClass(cls)

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.

wantDirectory(dirname)

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.

wantFile(file)

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.

wantFunction(function)

Is the function a test function?

wantMethod(method)

Is the method a test method?

wantModule(module)

Is the module a test module?

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

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:

filename_or_module:callable

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.

nose.selector.defaultSelector

alias of Selector