-
Notifications
You must be signed in to change notification settings - Fork 90
Closed
Labels
Description
Describe the bug
Flask v3.0.0, released Sep 30th, removed _request_ctx_stack, used in fixtures.py
To Reproduce
- Install
pytest-flask - Run your tests
- See import error
⚠️ Import error stacktrace ⚠️
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pytest/__main__.py", line 5, in <module>
raise SystemExit(pytest.console_main())
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 187, in console_main
code = main()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 145, in main
config = _prepareconfig(args, plugins)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 324, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_manager.py", line [11](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:12)5, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_callers.py", line 130, in _multicall
teardown[0].send(outcome)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/helpconfig.py", line 102, in pytest_cmdline_parse
config: Config = outcome.get_result()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_result.py", line 114, in get_result
raise exc.with_traceback(exc.__traceback__)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1017, in pytest_cmdline_parse
self.parse(args)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1305, in parse
self._preparse(args, addopts=addopts)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1188, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pluggy/_manager.py", line 398, in load_setuptools_entrypoints
plugin = ep.load()
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/importlib/metadata.py", line 86, in load
module = import_module(match.group('module'))
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/importlib/__init__.py", line [12](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:13)7, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pytest_invenio/plugin.py", line 25, in <module>
from .fixtures import (
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pytest_invenio/fixtures.py", line 22, in <module>
from pytest_flask.plugin import _make_test_response_class
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pytest_flask/plugin.py", line [14](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:15), in <module>
from .fixtures import accept_any
File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line [16](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:17)8, in exec_module
exec(co, module.__dict__)
File "/opt/hostedtoolcache/Python/3.9.[18](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:19)/x64/lib/python3.9/site-packages/pytest_flask/fixtures.py", line 6, in <module>
from flask import _request_ctx_stack
ImportError: cannot import name '_request_ctx_stack' from 'flask' (/opt/hostedtoolcache/Python/3.9.18/x[64](https://github.com/zenodo/zenodo-rdm/actions/runs/6382674986/job/17321782664#step:8:65)/lib/python3.9/site-packages/flask/__init__.py)
Environment (please complete the following information):
- OS: any
- Python Version 3.9
- pytest-flask version 1.2.0
Additional context
It looks like there's a deprecation warning already for using the fixture, so a possible path for a fix would be to:
- (Optional) "inline" the import inside the fixture function (to avoid affecting people still using the fixture with Flask <3.0.0, and give them a chance to respond to the deprecation warning).
- Remove the fixture completely and release
pytest-flaskv2.0.0
andrewmwilson, threeal, azmeuk, Ryu-CZ, dirkjanm and 5 more