Parameterized tests

nose2.tools.params(*paramList)[source]

Make a test function or method parameterized by parameters.

import unittest

from nose2.tools import params


@params(1, 2, 3)
def test_nums(num):
    assert num < 4


class Test(unittest.TestCase):

    @params((1, 2), (2, 3), (4, 5))
    def test_less_than(self, a, b):
        assert a < b

Parameters in the list may be defined as simple values, or as tuples. To pass a tuple as a simple value, wrap it in another tuple.

See also: Loader: Parameterized Tests