commit: 309963703004e919116a8399591de4e748d9f4fe Author: David Roman <davidroman96 <AT> gmail <DOT> com> AuthorDate: Tue Oct 10 10:21:42 2023 +0000 Commit: Haelwenn Monnier <contact <AT> hacktivis <DOT> me> CommitDate: Tue Oct 10 10:21:42 2023 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=30996370
dev-python/pytest-flask: fix compatibility with flask 3.0.0 Closes: https://bugs.gentoo.org/915522 Signed-off-by: David Roman <davidroman96 <AT> gmail.com> .../files/pytest-flask-fix-flask-compat.patch | 74 ++++++++++++++++++++++ .../pytest-flask/pytest-flask-1.2.0-r1.ebuild | 32 ++++++++++ 2 files changed, 106 insertions(+) diff --git a/dev-python/pytest-flask/files/pytest-flask-fix-flask-compat.patch b/dev-python/pytest-flask/files/pytest-flask-fix-flask-compat.patch new file mode 100644 index 0000000000..788d3e0dd6 --- /dev/null +++ b/dev-python/pytest-flask/files/pytest-flask-fix-flask-compat.patch @@ -0,0 +1,74 @@ +diff --git a/pytest_flask/fixtures.py b/pytest_flask/fixtures.py +index eb25861..486ec8b 100755 +--- a/pytest_flask/fixtures.py ++++ b/pytest_flask/fixtures.py +@@ -3,7 +3,6 @@ import socket + import warnings + + import pytest +-from flask import _request_ctx_stack + + from ._internal import _determine_scope + from ._internal import _make_accept_header +@@ -93,23 +92,6 @@ def config(app): + return app.config + + [email protected] +-def request_ctx(app): +- """The request context which contains all request relevant information, +- e.g. `session`, `g`, `flashes`, etc. +- """ +- warnings.warn( +- "In Werzeug 2.0.0, the Client request methods " +- "(client.get, client.post) always return an instance of TestResponse. This " +- "class provides a reference to the request object through 'response.request' " +- "The fixture 'request_ctx' is deprecated and will be removed in the future, using TestResponse.request " +- "is the prefered way.", +- DeprecationWarning, +- stacklevel=2, +- ) +- return _request_ctx_stack.top +- +- + @pytest.fixture(params=["application/json", "text/html"]) + def mimetype(request): + return request.param +diff --git a/pytest_flask/plugin.py b/pytest_flask/plugin.py +index bb4bf59..037f062 100755 +--- a/pytest_flask/plugin.py ++++ b/pytest_flask/plugin.py +@@ -19,7 +19,6 @@ from .fixtures import client + from .fixtures import client_class + from .fixtures import config + from .fixtures import live_server +-from .fixtures import request_ctx + from .pytest_compat import getfixturevalue + + +diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py +index a55fd98..b38af95 100755 +--- a/tests/test_fixtures.py ++++ b/tests/test_fixtures.py +@@ -16,21 +16,6 @@ class TestFixtures: + def test_accept_jsonp(self, accept_jsonp): + assert accept_jsonp == [("Accept", "application/json-p")] + +- def test_request_ctx(self, app, request_ctx): +- assert request_ctx.app is app +- +- def test_request_ctx_is_kept_around(self, client): +- res = client.get(url_for("index"), headers=[("X-Something", "42")]) +- """In werkzeug 2.0.0 the test Client provides a new attribute 'request' +- in the response class wich holds a reference to the request object that +- produced the respective response, making instrospection easier""" +- try: +- assert res.request.headers["X-Something"] == "42" +- except AttributeError: +- """This is the conventional (pre 2.0.0) way of reaching the +- request object, using flask.request global.""" +- assert request.headers["X-Something"] == "42" +- + def test_accept_mimetype(self, accept_mimetype): + mimestrings = [[("Accept", "application/json")], [("Accept", "text/html")]] + assert accept_mimetype in mimestrings diff --git a/dev-python/pytest-flask/pytest-flask-1.2.0-r1.ebuild b/dev-python/pytest-flask/pytest-flask-1.2.0-r1.ebuild new file mode 100644 index 0000000000..be4d90633e --- /dev/null +++ b/dev-python/pytest-flask/pytest-flask-1.2.0-r1.ebuild @@ -0,0 +1,32 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYPI_NO_NORMALIZE=1 +PYTHON_COMPAT=( python3_{11,12} pypy3 ) +inherit distutils-r1 pypi + +DESCRIPTION="A set of pytest fixtures to test Flask applications " +HOMEPAGE="http://pytest-flask.readthedocs.org" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" +IUSE="test" + +PATCHES=( "${FILESDIR}/${PN}-fix-flask-compat.patch" ) + +RDEPEND=" + dev-python/flask[${PYTHON_USEDEP}] + dev-python/werkzeug[${PYTHON_USEDEP}] +" + +DEPEND="${RDEPEND} + test? ( + dev-python/mock[${PYTHON_USEDEP}] + ) +" + +distutils_enable_tests pytest
