Loader: Test Generators

Load tests from generators.

This plugin implements loadTestFromTestCase(), loadTestsFromName() and loadTestFromModule() to enable loading tests from generators.

Generators may be functions or methods in test cases. In either case, they must yield a callable and arguments for that callable once for each test they generate. The callable and arguments may all be in one tuple, or the arguments may be grouped into a separate tuple:

def test_gen():
    yield check, 1, 2
    yield check, (1, 2)

To address a particular generated test via a command-line test name, append a colon (‘:’) followed by the index (starting from 1) of the generated case you want to execute.

Configuration [generators]


Sample configuration

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

always-on = True

Plugin class reference: Generators

class nose2.plugins.loader.generators.Generators[source]

Loader plugin that loads generator tests


Get generator test case names from test case class


Load tests from generator functions in a module


Load tests from generator named on command line


Load generator tests from test case