Repository navigation
Is there any way to create a fixture with a default indirect parameter? #10798
Unanswered
migue99angel
asked this question in
Q&A
Replies: 1 comment
|
For a fixture that should also work without indirect parametrization, give it an explicit fallback: @pytest.fixture
def populate_roles(request):
count = getattr(request, "param", 5)
created_roles = []
for _ in range(count):
# create role
...
return created_rolesThen both cases work: def test_default(populate_roles):
# uses 5
...and: @pytest.mark.parametrize("populate_roles", [3], indirect=True)
def test_three_roles(populate_roles):
# uses 3
...I would use Please mark this answer as accepted if it helped, thank you. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm thinking about creating a fixture parametrized by the indirect parameter as the documentation specified here:
But I am wondering if something like this is possible:
Actually, I am receiving this error:
AttributeError: 'SubRequest' object has no attribute 'param'Thank you! 😊
All reactions