import pytest
@pytest.mark.parametrize('a', [0, 1])
def test_increment(a):
pass
I want to apply custom-marker to a specific value of a marker. In the above-mentioned test case to be should be executed with
-m one is provided. -m two is provided.I tried the following snippet, but it doesn't work.
import pytest
@pytest.mark.parametrize('a', [pytest.mark.one(0), pytest.mark.two(1)])
def test_increment(a):
pass
I was able to provide custom marker to a parametrized test using pytest.param.
Document link: https://docs.pytest.org/en/latest/reference.html#pytest-param
Example: http://doc.pytest.org/en/latest/example/parametrize.html#set-marks-or-test-id-for-individual-parametrized-test
Snippet
@pytest.mark.parametrize('a', [pytest.param(0, marks=pytest.mark.one), pytest.param(1, marks=pytest.mark.two)])
def test_increment(a):
pass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With