0

I know this question has been asked several times. Yet here I'm seeking help because the existing answers are not addressing this specific question:

Here is what is working: I've a fixture called indexer (example use case), it simply returns an number starting from 0 to 9

import pytest

# Parametrized fixture
@pytest.fixture(params=range(10))
def indexer(request):
    return request.param

@pytest.mark.parametrize("a", [pytest.lazy_fixture("indexer")])
def test_indexer(a):
    assert isinstance(a, int)

I want to pass an argument for the range function in the fixture like: @pytest.fixture(params=range(max_range)). How can I do it?

I also know that there is a plugin called pytest-repeat. But that is not what I'm looking for.

Abbas
  • 3,872
  • 6
  • 36
  • 63
  • 1
    I dont think its possible because decorators and method declerations are executed before any method is executed. So there is no way of signaling this variable from a method. – Ilya Nov 05 '22 at 17:22

0 Answers0