Hi,
How can I pass two different arguments using parametrization marker.
Ex. @pytest.mark.parametrize(‘column_name’,[(‘Activity Start Time’)]) and I want to pass another argument like ‘column_name’ that can be used separately in same method
Hi,
How can I pass two different arguments using parametrization marker.
Ex. @pytest.mark.parametrize(‘column_name’,[(‘Activity Start Time’)]) and I want to pass another argument like ‘column_name’ that can be used separately in same method
The fist example in pytest's parameterisation documentation shows you how to do it: Parametrizing fixtures and test functions — pytest documentation
I personally prefer specifying parameters using a tuple:
import pytest
@pytest.mark.parametrize(("x", "exp"), [(1, 1), (2, 4)])
def test(x, exp):
assert x**2 == exp
And for named parameterisations:
import pytest
@pytest.mark.parametrize(
("x", "exp"),
[pytest.param(1, 1, id="one"),
pytest.param(2, 4, id="two")],
)
def test(x, exp):
assert x**2 == exp