-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
scope=session fixtures setup/teardown multiple times #3470
Comments
full log (Py2/Py3) https://gist.github.com/cielavenir/5cefaefe2a9374a666c97c851aead289 |
GitMate.io thinks possibly related issues are #1878 (session scoped fixtures get executed multiple times. I suspect I am using pytest wrong), #1738 (Have a way to force session scope teardown ), #583 (Add a class example for Setup/TearDown with fixtures), #3094 (Use fixtures to implement xUnit setup/teardown ), and #503 (Session fixtures invoked multiple times with xdist). |
I tried to patch FixtureManager like:
and now test_2.py cannot find fixture F. It looks like I really have to put fixtures in conftest.py. Sorry to have bothered you |
looks like patching also baseid works...
|
importation counts as extra definition - so this is a user error there is a plan to warn on multiple imports of the same fixture (as one issupposed to use a plugin/conftest |
fixed locally as https://github.com/cielavenir/pytest-session-fixture-globalize |
@cielavenir please document that this plugin may break even for minor or patch pytest releases ^^ its dabbling with the internals |
This introduces a race condition when using pytest-xdist with multiple processes. There does not seem to be a good way of running the cleanup once, even when using multiple processes. Related to pytest-dev/pytest#3470
__init__.py
test_1.py
test_2.py
this pytest tree shows:
I expect setup/teardown only once, since there are only one fixture definition.
If this is because global session fixtures are gathered multiple times, I think this can be fixed by checking module name in gathering.
The text was updated successfully, but these errors were encountered: