Session reference¶
Session¶
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.
-
argparse¶ An instance of
argparse.ArgumentParser. Plugins can use this directly to add arguments and argument groups, but must do so in their__init__methods.
-
pluginargs¶ 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.
-
hooks¶ The
nose2.events.PluginInterfaceinstance contains all available plugin methods and hooks.
-
plugins¶ The list of loaded – but not necessarily active – plugins.
-
verbosity¶ Current verbosity level. Default: 1.
-
startDir¶ Start directory of test run. Test discovery starts here. Default: current working directory.
-
topLevelDir¶ Top-level directory of test run. This directory is added to sys.path. Default: starting directory.
-
libDirs¶ Names of code directories, relative to starting directory. Default: [‘lib’, ‘src’]. These directories are added to sys.path and discovery if the exist.
-
testFilePattern¶ Pattern used to discover test module files. Default: test*.py
-
testMethodPrefix¶ Prefix used to discover test methods and functions: Default: ‘test’.
-
unittest¶ The config section for nose2 itself.
-
configClass¶ alias of
nose2.config.Config
-
get(section)[source]¶ Get a config section.
Parameters: section – The section name to retreive. Returns: instance of self.configClass.
-
isPluginLoaded(pluginName)[source]¶ Returns
Trueif a given plugin is loaded.Parameters: pluginName – the name of the plugin module: e.g. “nose2.plugins.layers”.
-
loadConfigFiles(*filenames)[source]¶ 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.
-
Config¶
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.Sectionbut 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
Truevalues. All other values areFalse.
-