Note that this is just one of the most common uses for the recent addition of funcargs to py.test .
In your case, you will receive:
def pytest_generate_tests(metafunc): if 'data' in metafunc.funcargnames: metafunc.parametrize('data', [1,2,3,4]) def test_data(data): assert data > 0
[EDIT] Perhaps I should add that you can also do this simply as
@pytest.mark.parametrize('data', [1,2,3,4]) def test_data(data): assert data > 0
So, I would say that py.test is a great environment for parameterized unit testing ...
source share