-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
doctest causes a working out of context RuntimeError with request #2485
Comments
flask.request
in a test file gives a RuntimeError
on Flask 2.2
This used to happen in pallets/flask#1680, but was fixed in Werkzeug #924 a long time ago. Seems it has started happening again. |
Running What's happening is that Werkzeug only sets Unfortunately, just the presence of I really think this is a bug in Python's |
This was reported in doctest years ago: python/cpython#70186. I think this is an issue with doctest, Sphinx uses For now, I'll set |
Migrating from Flask 2.1 to 2.2 failed a few unit tests of mine. It looks like we can no longer import
flask.request
top level in a test file (reproduced across Python 3.7, 3.8, 3.9, 3.10):This gives a
RuntimeError
:On my side the fix was simple: importing
flask.request
outside of the global scope, just when I actually need it (my actual tests create small Flask apps to test a client).Edit: forgot to mention that this only occurs when pytest is run with
--doctest-modules
The text was updated successfully, but these errors were encountered: