I want to achieve something like this:
my conftest.py will contain:
- fixture_1 - will do some manipulation with input such as a, b, c using request.param
- fixture_2 - will do some manipulation with input such as a, b, c using request.param
- fixture_3 - will do some manipulation with input such as a, b, c using request.param
@pytest.mark.parametrize('param_name', ['a', 'b', 'c'], indirect=True)
class TestDummy(object):
def test_x(self, fixture_1):
fixture_1_output = fixture_1
assert False
def test_y(self, fixture_2):
fixture_2_output = fixture_2
assert False
def test_z(self, fixture_3):
fixture_3_output = fixture_3
assert False
Any suggestion would be highly appreciated.
You cannot directly patameterize the fixture name this way. Either you use parametrize for each test separately:
(I moved the parameters into an extra function for convenience)
Or you have to do the parametrization dynamically based on the fixture name using
pytest_generate_tests:You need to determine which tests to parametrize - in this example all tests are parametrized which have exactly one fixture with a name starting with "fixture_", you may have to adapt ths to your needs.
In this example, the first 3 tests will be parametrized, but not the last one (
test_something_else).