-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Monkeypatch + Session Scope #1872
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
Have tried without the flask plugin, on python 3.5 and 2.7+, and pytest versions 3.0.0 and 3.0.1 |
That is a unfortunate leftover, shortly before 3.0 we had to pull back on invocation scoped fixtures due to a regression |
The plan is to bring them back in 3.1 |
This is a leftover when invocation-scoped fixtures were pulled back. Fix pytest-dev#1872
Thanks for removing a misleading example. What is the new way of monkey-patching in a session-scoped fixture? Do we have to patch and restore e.g. os.environ directly, can we use an instance of the MonkeyPatch class, or something else? |
currently not, so far we haven't been able to bring it back |
You can instantiate @pytest.fixture(scope='session')
def monkeypatch_session():
from _pytest.monkeypatch import MonkeyPatch
m = MonkeyPatch()
yield m
m.undo() But be aware that this may break in some feature release because it uses an internal API ( |
One can also use pytest-mock's |
From the documentation
However when running pytest 3.0.1
This is the error thrown
This is the fixture
The text was updated successfully, but these errors were encountered: