Load tests from parameterized functions and methods.
This plugin implements getTestCaseNames(), loadTestsFromModule(), and loadTestsFromName() to support loading tests from parameterized test functions and methods.
To parameterize a function or test case method, use nose2.tools.params().
To address a particular parameterized test via a command-line test name, append a colon (‘:’) followed by the index, starting from 1, of the case you want to execute.
The parameters plugin can work with the Such DSL, as long as the first argument of the test function is the “case” argument, followed by the other parameters:
from nose2.tools import such
from nose2.tools.params import params
with such.A('foo') as it:
@it.should('do bar')
@params(1,2,3)
def test(case, bar):
case.assert_(isinstance(bar, int))
@it.should('do bar and extra')
@params((1, 2), (3, 4) ,(5, 6))
def testExtraArg(case, bar, foo):
case.assert_(isinstance(bar, int))
case.assert_(isinstance(foo, int))
it.createTests(globals())
Default: | True |
---|---|
Type: | boolean |
The default configuration is equivalent to including the following in a unittest.cfg file.
[parameters]
always-on = True