nose2.main

class nose2.main.PluggableTestProgram(**kw)[source]

TestProgram that enables plugins.

Accepts the same parameters as unittest.TestProgram, but most of them are ignored as their functions are handled by plugins.

Parameters:
  • module – Module in which to run tests. Default: __main__()
  • defaultTest – Default test name. Default: None
  • argv – Command line args. Default: sys.argv
  • testRunnerIGNORED
  • testLoaderIGNORED
  • exit – Exit after running tests?
  • verbosity – Base verbosity
  • failfastIGNORED
  • catchbreakIGNORED
  • bufferIGNORED
  • plugins – List of additional plugin modules to load
  • excludePlugins – List of plugin modules to exclude
  • extraHooks – List of hook names and plugin instances to register with the session’s hooks system. Each item in the list must be a 2-tuple of (hook name, plugin instance)
sessionClass

The class to instantiate to create a test run configuration session. Default: nose2.session.Session

loaderClass

The class to instantiate to create a test loader. Default: nose2.loader.PluggableTestLoader.

Warning

Overriding this attribute is the only way to customize the test loader class. Passing a test loader to __init__() does not work.

runnerClass

The class to instantiate to create a test runner. Default: nose2.runner.PluggableTestRunner.

Warning

Overriding this attribute is the only way to customize the test runner class. Passing a test runner to __init__() does not work.

defaultPlugins

List of default plugin modules to load.

createTests()[source]

Create top-level test suite

findConfigFiles(cfg_args)[source]

Find available config files

classmethod getCurrentSession()[source]

Returns the current session, or None if no nose2.session.Session is running.

handleArgs(args)[source]

Handle further arguments.

Handle arguments parsed out of command line after plugins have been loaded (and injected their argument configuration).

handleCfgArgs(cfg_args)[source]

Handle initial arguments.

Handle the initial, pre-plugin arguments parsed out of the command line.

loadPlugins()[source]

Load available plugins

self.defaultPlugins`() and self.excludePlugins() are passed to the session to alter the list of plugins that will be loaded.

This method also registers any (hook, plugin) pairs set in self.hooks. This is a good way to inject plugins that fall outside of the normal loading procedure, for example, plugins that need some runtime information that can’t easily be passed to them through the configuration system.

loaderClass

alias of PluggableTestLoader

parseArgs(argv)[source]

Parse command line args

Parses arguments and creates a configuration session, then calls createTests().

runTests()[source]

Run tests

runnerClass

alias of PluggableTestRunner

sessionClass

alias of Session

setInitialArguments()[source]

Set pre-plugin command-line arguments.

This set of arguments is parsed out of the command line before plugins are loaded.

nose2.main.discover(*args, **kwargs)[source]

Main entry point for test discovery.

Running discover calls nose2.main.PluggableTestProgram, passing through all arguments and keyword arguments except module: module is discarded, to force test discovery.

nose2.main.main

alias of PluggableTestProgram