You will probably want to use the pytest_generate_tests()
hook as described here: https://docs.pytest.org/en/stable/parametrize.html#pytest-generate-tests This allows you to read the csv file and parametrize the tests you want based on it's contents.
Update:
The updated question seems not entirely clear, but I'm assuming you need to test something on a row as well as on a column. This simply asks for two tests:
def test_row(row):
assert row # or whatever
def test_column(col):
assert col # or whatever
Now all that remains is to create the parametrized fixtures for row
and col
using the pytest_generate_tests()
hook. So in the conftest.py
file:
def test_generate_tests(metafunc):
rows = read_csvrows()
if 'row' in metafunc.fixturenames:
metafunc.parametrize('row', rows)
if 'col' in metafunc.fixturenames:
metafunc.parametrize('col', list(itertools.chain(*rows)))
Notice the use of the recommended metafunc.parametrize()
function instead of the deprecated metafunc.addcall()