Override a pytest parameterized functions name
you can also use pytest parametrize wrapper from: https://github.com/singular-labs/parametrization or on pypi
pip install pytest-parametrization
your code would look like:
from parametrization import Parametrization
class TestMe:
@Parametrization.autodetect_parameters()
@Parametrization.case(name="testA", op='plus', value=3)
@Parametrization.case(name="testB", op='minus', value=1)
def test_ops(self, op, value):
...
which is equals to:
class TestMe:
@pytest.mark.parametrize(
("op", "value"),
[
("plus", "3"),
("minus", "1"),
],
ids=['testA', 'testB']
)
def test_ops(self, op, value):
...
You're looking for the ids
argument of pytest.mark.parametrize
:
list of string ids, or a callable. If strings, each is corresponding to the argvalues so that they are part of the test id. If callable, it should take one argument (a single argvalue) and return a string or return None.
Your code would look like
@pytest.mark.parametrize(
("testname", "op", "value"),
[
("testA", "plus", "3"),
("testB", "minus", "1"),
],
ids=['testA id', 'testB id']
)
def test_industry(self, testname, op, value):