dev-python/responses: Backport urllib3-2 fix

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2023-05-29 14:08:11 +02:00
parent d7f12d1799
commit e3d86e66e8
2 changed files with 140 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
From 071306524af1b4ee1797c45a46525274d271a9b6 Mon Sep 17 00:00:00 2001
From: Maksim Beliaev <beliaev.m.s@gmail.com>
Date: Tue, 9 May 2023 21:14:27 +0200
Subject: [PATCH] fix test compatibility with urllib3 (#636)
- Upgrade urllib3 and requests
---
CHANGES | 6 ++++++
README.rst | 2 +-
responses/tests/test_responses.py | 9 +++++----
setup.py | 4 ++--
4 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/CHANGES b/CHANGES
index f3a0080..f6a8d12 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+0.23.2
+------
+
+* Updated dependency to urllib3>=2 and requests>=2.30.0. See #635
+
+
0.23.1
------
diff --git a/README.rst b/README.rst
index cfdf0b2..7d790eb 100644
--- a/README.rst
+++ b/README.rst
@@ -17,7 +17,7 @@ A utility library for mocking out the ``requests`` Python library.
.. note::
- Responses requires Python 3.7 or newer, and requests >= 2.22.0
+ Responses requires Python 3.7 or newer, and requests >= 2.30.0
Table of Contents
diff --git a/responses/tests/test_responses.py b/responses/tests/test_responses.py
index 90c1d65..c264e4e 100644
--- a/responses/tests/test_responses.py
+++ b/responses/tests/test_responses.py
@@ -1498,9 +1498,10 @@ def test_auto_calculate_content_length_doesnt_override_existing_value():
headers={"Content-Length": "2"},
auto_calculate_content_length=True,
)
- resp = requests.get(url)
- assert_response(resp, "test")
- assert resp.headers["Content-Length"] == "2"
+ with pytest.raises(ChunkedEncodingError) as excinfo:
+ requests.get(url)
+
+ assert "IncompleteRead(4 bytes read, -2 more expected)" in str(excinfo.value)
run()
assert_reset()
@@ -2416,7 +2417,7 @@ class TestMaxRetry:
total=total,
backoff_factor=0.1,
status_forcelist=[500],
- method_whitelist=["GET", "POST", "PATCH"],
+ allowed_methods=["GET", "POST", "PATCH"],
raise_on_status=raise_on_status,
)
)
diff --git a/setup.py b/setup.py
index 6d01ad2..f61b30a 100644
--- a/setup.py
+++ b/setup.py
@@ -17,8 +17,8 @@ from setuptools.command.test import test as TestCommand
setup_requires = []
install_requires = [
- "requests>=2.22.0,<3.0",
- "urllib3>=1.25.10",
+ "requests>=2.30.0,<3.0",
+ "urllib3>=2.0.0,<3.0",
"pyyaml",
"types-PyYAML",
"typing_extensions; python_version < '3.8'",
--
2.40.1

View File

@@ -0,0 +1,55 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{10..11} pypy3 )
inherit distutils-r1 pypi
DESCRIPTION="Utility for mocking out the Python Requests library"
HOMEPAGE="
https://pypi.org/project/responses/
https://github.com/getsentry/responses/
"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
# tomli backend is optional now, with pyyaml being the new default.
# However, keeping it unconditional here for backwards compatibility.
RDEPEND="
dev-python/pyyaml[${PYTHON_USEDEP}]
<dev-python/requests-3[${PYTHON_USEDEP}]
>=dev-python/requests-2.30.0[${PYTHON_USEDEP}]
$(python_gen_cond_dep '
dev-python/tomli[${PYTHON_USEDEP}]
' 3.{8..10})
dev-python/tomli-w[${PYTHON_USEDEP}]
<dev-python/urllib3-3[${PYTHON_USEDEP}]
>=dev-python/urllib3-2.0.0[${PYTHON_USEDEP}]
"
BDEPEND="
test? (
dev-python/pytest-httpserver[${PYTHON_USEDEP}]
)
"
distutils_enable_tests pytest
PATCHES=(
"${FILESDIR}/${P}-urllib3-2.patch"
)
src_prepare() {
distutils-r1_src_prepare
# remove unnecessary RDEP on type stubs
sed -i -e '/types-/d' setup.py || die
}
python_test() {
epytest -p no:localserver
}