It would be good to have fixtures with dinamically changed / different scopes #12673
Labels
topic: fixtures
anything involving fixtures directly or indirectly
type: question
general question, might be closed after 2 weeks of inactivity
What's the problem this feature will solve?
I create random users for the tests. I use factories according to https://docs.pytest.org/en/latest/how-to/fixtures.html#factories-as-fixtures
The user creation is quite expensive (in time), so I would like to create only one user for negative test cases, and one for every positive test case when the user state is changed during the test.
My idea was that create user for negative tests with module scope and use function scope for positive ones. But it is not possible. (I duplicated the fixtures with different scopes, but it is not good)
Describe the solution you'd like
I do not know how to solve this
Alternative Solutions
As I wrote this feature request, it got to my mind that there is a class scope, and that can solve this.:
Create a class for negative test cases and one class for each positive, and it solves the issue.
Perhaps documenting this with an example (two class type: one for all negative test cases and several for the positive ones) should be enough / good
BR,
George
Additional context
The text was updated successfully, but these errors were encountered: