Load tests from test functions in modules.
This plugin responds to loadTestsFromModule() by adding test cases for all test functions in the module to event.extraTests. It uses session.testMethodPrefix to find test functions.
Functions that are generators, have param lists, or take arguments are not collected.
This plugin also implements loadTestsFromName() to enable loading tests from dotted function names passed on the command line.
Test functions can specify setup and teardown fixtures as attributes on the function, for example:
x = 0
def test():
assert x
def setup():
global x
x = 1
def teardown():
global x
x = 1
test.setup = setup
test.teardown = teardown
The setup attribute may be named setup, setUp or setUpFunc. The teardown attribute may be named teardown, ‘tearDown`` or tearDownFunc.
The other significant attribute that may be set on a test function is paramList. When paramList is set, the function will be collected by the parameterized test loader. The easiest way to set paramList is with the nose2.tools.params() decorator.