How to mark individual parameterized tests with a marker?

Viewed 783

I have been trying to parameterize my tests using @pytest.mark.parametrize, and I have a marketer @pytest.mark.test("1234"), I use the value from the test marker to do post the results to JIRA. Note the value given for the marker changes for every test_data. Essentially the code looks something like below.

@pytest.mark.foo
@pytest.mark.parametrize(("n", "expected"),[
    (1, 2),
    (2, 3)])
def test_increment(n, expected):
     assert n + 1 == expected

I want to do something like

@pytest.mark.foo
@pytest.mark.parametrize(("n", "expected"), [
    (1, 2,@pytest.mark.test("T1")),
    (2, 3,@pytest.mark.test("T2"))
])

How to add the marker when using parameterized tests given that the value of the marker is expected to change with each test?

1 Answers
Related