-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Session scoped fixture run multiple times when adding fixture via metafunc #5738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
OK so Ive managed to find a workaround but I have no idea if thats the correct way or an ugly hack! By adding
and creating a new fixture:
The issue was fixed:
Only thing is that now, instead of the order: The order is: test1-iteration1 Which is kinda weird but..oh well.. Thanks. |
Good find, this narrows the issue down a bit |
Thanks for the report @Drau! Not sure how to help with your issue, but FYI you can enable syntax highlighting for code blocks on GitHub which makes them a bit easier to read 😄 |
I think this issue can be closed. Tested on pytest 5.4 and 6.0, both behave as expected:
|
Hi Drau: can u tell me how r u able to achieve this in detail. M also trying to achieve the same. Any help is much appreciated. |
pytest v5.0.1
(All code can be found here: example repo)
When defining a session scoped fixture inside
pytest_generate_tests hook
,while also using
metafunc.parametrize
to make all tests repeat N times,Every fixture that uses the newly created job_id fixture, is called N times (Once before every test iteration)
conftest.py
test_1.py
Result: fix1 fixture is called, then the 2 tests are called, then again fix1 and so on...
I would expect that all session scoped fixtures will run only once.
The text was updated successfully, but these errors were encountered: