Mapping exceptions to test outcomes

Map exceptions to test outcomes.

This plugin implements setTestOutcome() to enable simple mapping of exception classes to existing test outcomes.

By setting a list of exception classes in a nose2 config file, you can configure exceptions that would otherwise be treated as test errors, to be treated as failures or skips instead:

[outcomes]
always-on = True
treat-as-fail = NotImplementedError
treat-as-skip = TodoError
                IOError

Enable this Plugin

This plugin is built-in, but not loaded by default.

Even if you specify always-on = True in the configuration, it will not run unless you also enable it. You can do so by putting the following in a unittest.cfg or nose2.cfg file

[unittest]
plugins = nose2.plugins.outcomes

The plugins parameter may contain a list of plugin names, including nose2.plugins.outcomes

Configuration [outcomes]

always-on
Default:False
Type:boolean
treat-as-fail
Default:[]
Type:list
treat-as-skip
Default:[]
Type:list

Sample configuration

The default configuration is equivalent to including the following in a unittest.cfg file.

[outcomes]
always-on = False
treat-as-fail = 
treat-as-skip = 

Command-line options

--set-outcomes DEFAULT

Treat some configured exceptions as failure or skips

Plugin class reference: Outcomes

class nose2.plugins.outcomes.Outcomes[source]

Map exceptions to other test outcomes

setTestOutcome(event)[source]

Update outcome, exc_info and reason based on configured mappings