-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
pytester configuration leaks in main pytest configuration #4495
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
its not so much leaking, but rather a rather massive/painful bug about pytests internal state as pytest does in fact patch the object pytest.config, but never undoes the patch |
Lines 170 to 172 in ecc5c84
|
also ref #3050 |
It would be quite unfortunate if |
@youtux why would it need it that way? |
Because pytest-bdd generates test items from |
all that happens past pytest-configure time, just configure your plugin at that time instead of getting the globals later |
I don't really get what you are suggesting, @RonnyPfannschmidt |
does this become "wontfix" given the resolution of #3050 (deprecating |
@asottile we can debate on whether we want pytester to remember/reset the value |
@RonnyPfannschmidt could you please tell us what you meant? Please give us some hint or link to the documentation. Because of the problem with |
@sliwinski-milosz to fix pytest-bdd, the pytester plugin would have t fix the reference - note that pytest.config will go away with the next major release |
I think this bug is even worse. It is not only about undoing the patch of the config. If I understand correctly hooks are affected too. Lets say for now that we configure our plugin using Please take a look at following steps:
Important part is that the testdir test is testing config. One solution for above is to run our testdir test in subprocess by using |
@sliwinski-milosz for correctness you need pytest_configure and pytest_unconfigure paired |
Ah ok. In our case unconfigure means bring previous values back. |
@sliwinski-milosz with the current layering of pytest, you have to track it yourself, its quite a pain, |
Thanks! All clear now! I have opened pull request for pytest-bdd in which I use config stack. It seems that it works fine :) |
@sliwinski-milosz great job |
Closing as we removed the config global |
I discover this while debugging a failure in pytest-bdd (see pytest-dev/pytest-bdd#276).
It seems that the ini configuration created by
testdir.makeini
function leaks in the main pytest configuration.Here it is a test that reproduce the issue:
This is the configuration I am using:
Python 3.7.1 on Mac OS 10.14.1
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: