I have the following example unit test set up. There are several classes with their own fixtures. I am showing the 5th class here:
import pytest
class TestOperator1:
....
class TestOperator5:
@pytest.fixture(scope="class"):
def runm0(self, request):
yield request.param+10
@pytest.fixture(scope="class"):
def runm1(self, request):
yield request.param+20
@pytest.mark.parametrize("runm0, runm1", [(5, 10), (20, 30)])
def test_1(self, runm0, runm1):
assert runm0*runm1 == 10
@pytest.mark.parametrize("runm0, runm1", [(5, 10), (20, 30)])
def test_2(self, runm0, runm1):
assert runm0*runm1 == 20
@pytest.mark.parametrize("runm0, runm1", [(5, 10), (20, 30)])
def test_3(self, runm0, runm1):
assert runm0*runm1 == 30
How can I write the parametrize code once and have it apply to all test functions within the class? Decorating the class with parametrize appears to be the solution, but how would that work if the fixtures I want to parametrize on are defined within the class?