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]

always-on
Default

True

Type

boolean

Sample configuration

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

[generators]
always-on = True

Plugin class reference: Generators

class nose2.plugins.loader.generators.Generators(*args, **kwargs)[source]

Loader plugin that loads generator tests

getTestCaseNames(event)[source]

Get generator test case names from test case class

loadTestsFromModule(event)[source]

Load tests from generator functions in a module

loadTestsFromName(event)[source]

Load tests from generator named on command line

loadTestsFromTestCase(event)[source]

Load generator tests from test case