commit: ddc4ed20fe843e71d48ef04d8f3abf843e6aaaf8 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sat May 14 11:57:01 2022 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sat May 14 13:00:33 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddc4ed20
dev-python/httpretty: Use PEP517 build Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> .../httpretty/files/httpretty-1.1.4-pytest.patch | 121 +++++++++++++++++++++ dev-python/httpretty/httpretty-1.1.4-r1.ebuild | 78 +++++++++++++ 2 files changed, 199 insertions(+) diff --git a/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch b/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch new file mode 100644 index 000000000000..ccb465ce98ea --- /dev/null +++ b/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch @@ -0,0 +1,121 @@ +From 299d50c9cb0ba73343d1a88c202e17f6599fde54 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org> +Date: Sat, 14 May 2022 13:39:13 +0200 +Subject: [PATCH] Fix functional tests compatibility with pytest + +Provide a default value for test parameters provided by decorators +in order to prevent pytest from recognizing them as fixtures. This +is the smaller change needed to run the complete test suite via pytest. + +Fixes #449 +--- + tests/functional/test_bypass.py | 8 ++++---- + tests/functional/test_debug.py | 10 +++++----- + tests/functional/test_requests.py | 2 +- + 3 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/tests/functional/test_bypass.py b/tests/functional/test_bypass.py +index e85dfac..cf7e75d 100644 +--- a/tests/functional/test_bypass.py ++++ b/tests/functional/test_bypass.py +@@ -88,7 +88,7 @@ def stop_tcp_server(context): + + @httpretty.activate + @that_with_context(start_http_server, stop_http_server) +-def test_httpretty_bypasses_when_disabled(context): ++def test_httpretty_bypasses_when_disabled(context=None): + "httpretty should bypass all requests by disabling it" + + httpretty.register_uri( +@@ -122,7 +122,7 @@ def test_httpretty_bypasses_when_disabled(context): + + @httpretty.activate(verbose=True) + @that_with_context(start_http_server, stop_http_server) +-def test_httpretty_bypasses_a_unregistered_request(context): ++def test_httpretty_bypasses_a_unregistered_request(context=None): + "httpretty should bypass a unregistered request by disabling it" + + httpretty.register_uri( +@@ -145,7 +145,7 @@ def test_httpretty_bypasses_a_unregistered_request(context): + + @httpretty.activate(verbose=True) + @that_with_context(start_tcp_server, stop_tcp_server) +-def test_using_httpretty_with_other_tcp_protocols(context): ++def test_using_httpretty_with_other_tcp_protocols(context=None): + "httpretty should work even when testing code that also use other TCP-based protocols" + + httpretty.register_uri( +@@ -163,7 +163,7 @@ def test_using_httpretty_with_other_tcp_protocols(context): + + @httpretty.activate(allow_net_connect=False) + @that_with_context(start_http_server, stop_http_server) +-def test_disallow_net_connect_1(context, verbose=True): ++def test_disallow_net_connect_1(context=None, verbose=True): + """ + When allow_net_connect = False, a request that otherwise + would have worked results in UnmockedError. +diff --git a/tests/functional/test_debug.py b/tests/functional/test_debug.py +index 86bf09e..ee742f3 100644 +--- a/tests/functional/test_debug.py ++++ b/tests/functional/test_debug.py +@@ -39,7 +39,7 @@ def create_socket(context): + @skip('not currently supported') + @httprettified + @scenario(create_socket) +-def test_httpretty_debugs_socket_send(context): ++def test_httpretty_debugs_socket_send(context=None): + "HTTPretty should forward_and_trace socket.send" + + expect(context.sock.send).when.called_with(b'data').to.throw( +@@ -50,7 +50,7 @@ def test_httpretty_debugs_socket_send(context): + @skip('not currently supported') + @httprettified + @scenario(create_socket) +-def test_httpretty_debugs_socket_sendto(context): ++def test_httpretty_debugs_socket_sendto(context=None): + "HTTPretty should forward_and_trace socket.sendto" + + expect(context.sock.sendto).when.called.to.throw( +@@ -61,7 +61,7 @@ def test_httpretty_debugs_socket_sendto(context): + @skip('not currently supported') + @httprettified + @scenario(create_socket) +-def test_httpretty_debugs_socket_recvfrom(context): ++def test_httpretty_debugs_socket_recvfrom(context=None): + "HTTPretty should forward_and_trace socket.recvfrom" + + expect(context.sock.recvfrom).when.called.to.throw( +@@ -72,7 +72,7 @@ def test_httpretty_debugs_socket_recvfrom(context): + @skip('not currently supported') + @httprettified + @scenario(create_socket) +-def test_httpretty_debugs_socket_recv_into(context): ++def test_httpretty_debugs_socket_recv_into(context=None): + "HTTPretty should forward_and_trace socket.recv_into" + buf = bytearray() + expect(context.sock.recv_into).when.called_with(buf).to.throw( +@@ -83,7 +83,7 @@ def test_httpretty_debugs_socket_recv_into(context): + @skip('not currently supported') + @httprettified + @scenario(create_socket) +-def test_httpretty_debugs_socket_recvfrom_into(context): ++def test_httpretty_debugs_socket_recvfrom_into(context=None): + "HTTPretty should forward_and_trace socket.recvfrom_into" + + expect(context.sock.recvfrom_into).when.called.to.throw( +diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py +index 55aa109..04a5e80 100644 +--- a/tests/functional/test_requests.py ++++ b/tests/functional/test_requests.py +@@ -768,7 +768,7 @@ def test_unicode_querystrings(): + + + @use_tornado_server +-def test_recording_calls(port): ++def test_recording_calls(port=None): + ("HTTPretty should be able to record calls") + # Given a destination path: + destination = FIXTURE_FILE("recording-1.json") +-- +2.35.1 + diff --git a/dev-python/httpretty/httpretty-1.1.4-r1.ebuild b/dev-python/httpretty/httpretty-1.1.4-r1.ebuild new file mode 100644 index 000000000000..dd276c46a534 --- /dev/null +++ b/dev-python/httpretty/httpretty-1.1.4-r1.ebuild @@ -0,0 +1,78 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{8..10} ) + +inherit distutils-r1 + +DESCRIPTION="HTTP client mock for Python" +HOMEPAGE=" + https://github.com/gabrielfalcao/httpretty/ + https://pypi.org/project/httpretty/ +" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +SLOT="0" +LICENSE="MIT" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~sparc ~x86" + +RDEPEND=" + dev-python/urllib3[${PYTHON_USEDEP}] +" +BDEPEND=" + test? ( + dev-python/freezegun[${PYTHON_USEDEP}] + >=dev-python/requests-1.1[${PYTHON_USEDEP}] + dev-python/sure[${PYTHON_USEDEP}] + >=www-servers/tornado-2.2[${PYTHON_USEDEP}] + )" +# These are optional test deps, that are used to test compatibility +# with various HTTP libs. We prefer pulling them in whenever possible +# to increase test coverage but we can live without them. +# We're skipping redis entirely since it requires a running server. +BDEPEND+=" + test? ( + >=dev-python/boto3-1.17.72[${PYTHON_USEDEP}] + dev-python/httplib2[${PYTHON_USEDEP}] + >=dev-python/httpx-0.18.1[${PYTHON_USEDEP}] + dev-python/pyopenssl[${PYTHON_USEDEP}] + $(python_gen_cond_dep ' + >=dev-python/eventlet-0.25.1[${PYTHON_USEDEP}] + ' python3_{8..9}) + ) +" + +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}/${P}-pytest.patch" +) + +python_test() { + local EPYTEST_IGNORE=( + # this seems to be a stress test + tests/bugfixes/pytest/test_426_mypy_segfault.py + # passthrough tests require Internet access + tests/functional/test_passthrough.py + ) + + local ignore_by_dep=( + dev-python/boto3:tests/bugfixes/nosetests/test_416_boto3.py + dev-python/eventlet:tests/bugfixes/nosetests/test_eventlet.py + dev-python/httplib2:tests/functional/test_httplib2.py + dev-python/httpx:tests/bugfixes/nosetests/test_414_httpx.py + dev-python/pyopenssl:tests/bugfixes/nosetests/test_417_openssl.py + ) + + local x + for x in "${ignore_by_dep[@]}"; do + if ! has_version "${x%:*}[${PYTHON_USEDEP}]"; then + EPYTEST_IGNORE+=( "${x#*:}" ) + fi + done + + epytest +}