Session reference


In nose2, all configuration for a test run is encapsulated in a Session instance. Plugins always have the session available as self.session.

class nose2.session.Session[source]

Configuration session.

Encapsulates all configuration for a given test run.


An instance of argparse.ArgumentParser. Plugins can use this directly to add arguments and argument groups, but must do so in their __init__ methods.


The argparse argument group in which plugins (by default) place their command-line arguments. Plugins can use this directly to add arguments, but must do so in their __init__ methods.


The instance contains all available plugin methods and hooks.


The list of loaded – but not necessarily active – plugins.


Current verbosity level. Default: 1.


Start directory of test run. Test discovery starts here. Default: current working directory.


Top-level directory of test run. This directory is added to sys.path. Default: starting directory.


Names of code directories, relative to starting directory. Default: [‘lib’, ‘src’]. These directories are added to sys.path and discovery if the exist.


Pattern used to discover test module files. Default: test*.py


Prefix used to discover test methods and functions: Default: ‘test’.


The config section for nose2 itself.


alias of Config


Get a config section.

Parameters:section – The section name to retreive.
Returns:instance of self.configClass.

Returns True if a given plugin is loaded.

Parameters:pluginName – the name of the plugin module: e.g. “nose2.plugins.layers”.

Load config files.

Parameters:filenames – Names of config files to load.

Loads all names files that exist into self.config.

loadPlugins(modules=None, exclude=None)[source]

Load plugins.

Parameters:modules – List of module names from which to load plugins.

Load plugins from a module.

Parameters:module – A python module containing zero or more plugin classes.

Add code directories to sys.path


Register a plugin.

Parameters:plugin – A instance.

Register the plugin with all methods it implements.


Configuration values loaded from config file sections are made available to plugins in Config instances. Plugins that set configSection will have a Config instance available as self.config.

class nose2.config.Config(items)[source]

Configuration for a plugin or other entities.

Encapsulates configuration for a single plugin or other element. Corresponds to a ConfigParser.Section but provides an extended interface for extracting items as a certain type.

as_bool(key, default=None)[source]

Get key value as boolean

1, t, true, on, yes and y (case insensitive) are accepted as True values. All other values are False.

as_float(key, default=None)[source]

Get key value as float

as_int(key, default=None)[source]

Get key value as integer

as_list(key, default=None)[source]

Get key value as list.

The value is split into lines and returned as a list. Lines are stripped of whitespace, and lines beginning with # are skipped.

as_str(key, default=None)[source]

Get key value as str

get(key, default=None)[source]

Get key value