I feel like this is asking something super obvious, but I can't seem to figure it out.
Let's take this example from the Pytest docs:
@pytest.fixture
def fixt(request):
return request.param * 3
@pytest.mark.parametrize("fixt", ["a", "b"], indirect=True)
def test_indirect(fixt):
assert len(fixt) == 3
assume that instead, I want to check assert fixt == letter*3
. That would mean that I need to be able to access the parameter not only in the fixture, but also in the test. In a way it would be like passing both True and False to the indirect
argument.
How can I do this?
Practical use case: my fixture sets up some external actor, with which my test is communicating. The parametrization configures it differently, based on the parameter. In order to test correctly, I need to know what parameters it was configured with.
Currently I solved it by letting the fixture return the request.param object again, but that doesn't really feel like the most correct way to do this.