How can you provide custom IDs for each test case in a parameterized pytest function to make test reports more readable?

Python interview question for Advanced practice.

Answer

Both A and C are valid methods.

Explanation

You can either provide a list of strings to the 'ids' parameter of the decorator, or use pytest.param(value, id='some-id') for individual items in the parameter list. Both are common practices.

Related Questions