I've the following tests:
@pytest.mark.parametrize(
"nums",
[[3, 1, 5, 4, 2], [2, 6, 4, 3, 1, 5], [1, 5, 6, 4, 3, 2]]
)
def test_cyclic_sort(nums):
pass
@pytest.mark.parametrize(
"nums, missing",
[([4, 0, 3, 1], 2)]
)
def test_find_missing_number(nums, missing):
pass
I'd like to customize the test names to include the input array. I've read the pytest docs, and this question and this question, but none answer the following questions:
- What is passed to the id func? In my code above, the first test takes one parameter, the second takes two.
- pytest docs use a top-level function for id, whereas I'd like to put my tests in a class and use a
@staticmethod
. Trying to reference the static method withTestClass.static_method
from insideTestClass
gives an error in PyCharm; what is the correct syntax for doing this?
Edit: Created https://github.com/pytest-dev/pytest/issues/8448.