- Update to 0.23.1:

- Remove `tomli` import. See #630
  - Add Python 3.11 support
  - Fix type annotations of `CallList`. See #593
  - `request` object is attached to any custom exception provided
    as `Response` `body` argument. See #588
  - Fixed mocked responses leaking between tests when
    `assert_all_requests_are_fired` and a request was not fired.
  - [BETA] Default recorder format was changed to YAML.
    Added `responses.RequestsMock._parse_response_file` and
    `responses._recorder.Recorder.dump_to_file` methods that
    allow users to override default parser to eg toml, json
  - Update `requests` dependency to the version of 2.22.0 or
    higher. See #584.
  - [BETA] Added possibility to record responses to TOML files
    via `@_recorder.record(file_path="out.toml")` decorator.
  - [BETA] Added possibility to replay responses
    (populate registry) from TOML files via
    `responses._add_from_file(file_path="out.toml")` method.
  - Fix type for the `mock`'s patcher object. See #556
  - Fix type annotation for `CallList`
  - Add `passthrough` argument to `BaseResponse` object. See #557
  - Fix `registries` leak. See #563
  - `OriginalResponseShim` is removed. See #585
  - Add support for the `loose` version of `json_params_matcher`
    via named argument `strict_match`. See #551
  - Add lists support as JSON objects in
    `json_params_matcher`. See #559
  - Added project links to pypi listing.
  - `delete`, `get`, `head`, `options`, `patch`,

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-responses?expand=0&rev=51
This commit is contained in:
Matej Cepl 2023-05-06 15:28:42 +00:00 committed by Git OBS Bridge
parent 7cb08faed5
commit f22070e9d3
7 changed files with 176 additions and 85 deletions

15
compat-urllib3-2.patch Normal file
View File

@ -0,0 +1,15 @@
---
responses/tests/test_responses.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/responses/tests/test_responses.py
+++ b/responses/tests/test_responses.py
@@ -2417,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,
)
)

View File

@ -1,70 +0,0 @@
---
responses/__init__.py | 23 ++++++++++++-----------
responses/tests/test_responses.py | 3 +++
2 files changed, 15 insertions(+), 11 deletions(-)
--- a/responses/__init__.py
+++ b/responses/__init__.py
@@ -7,7 +7,6 @@ from collections.abc import Sized
from functools import wraps
from http import client
from itertools import groupby
-from re import Pattern
from threading import Lock as _ThreadingLock
from typing import TYPE_CHECKING
from typing import Any
@@ -34,9 +33,11 @@ from responses.matchers import urlencode
from responses.registries import FirstMatchRegistry
try:
- from typing_extensions import Literal
-except ImportError: # pragma: no cover
- from typing import Literal # type: ignore # pragma: no cover
+ from re import Pattern
+except ImportError:
+ from re import compile
+ Pattern = type(compile(''))
+ del compile
try:
from requests.packages.urllib3.response import HTTPResponse
@@ -623,13 +624,13 @@ class OriginalResponseShim(object):
class RequestsMock(object):
- DELETE: Literal["DELETE"] = "DELETE"
- GET: Literal["GET"] = "GET"
- HEAD: Literal["HEAD"] = "HEAD"
- OPTIONS: Literal["OPTIONS"] = "OPTIONS"
- PATCH: Literal["PATCH"] = "PATCH"
- POST: Literal["POST"] = "POST"
- PUT: Literal["PUT"] = "PUT"
+ DELETE: Any = "DELETE"
+ GET: Any = "GET"
+ HEAD: Any = "HEAD"
+ OPTIONS: Any = "OPTIONS"
+ PATCH: Any = "PATCH"
+ POST: Any = "POST"
+ PUT: Any = "PUT"
response_callback: Optional[Callable[[Any], Any]] = None
--- a/responses/tests/test_responses.py
+++ b/responses/tests/test_responses.py
@@ -3,6 +3,7 @@
import inspect
import os
import re
+import sys
import warnings
from io import BufferedReader
from io import BytesIO
@@ -562,6 +563,8 @@ def test_callback():
assert_reset()
+@pytest.mark.skipif(sys.version_info[:2] <= (3, 6),
+ reason="test doesn't work on Python 3.6")
def test_deprecated_package_attributes():
"""Validates that deprecation warning is raised when package attributes are called."""
# keep separate context manager to avoid leakage

View File

@ -1,3 +1,48 @@
-------------------------------------------------------------------
Fri May 5 18:05:59 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Update to 0.23.1:
- Remove `tomli` import. See #630
- Add Python 3.11 support
- Fix type annotations of `CallList`. See #593
- `request` object is attached to any custom exception provided
as `Response` `body` argument. See #588
- Fixed mocked responses leaking between tests when
`assert_all_requests_are_fired` and a request was not fired.
- [BETA] Default recorder format was changed to YAML.
Added `responses.RequestsMock._parse_response_file` and
`responses._recorder.Recorder.dump_to_file` methods that
allow users to override default parser to eg toml, json
- Update `requests` dependency to the version of 2.22.0 or
higher. See #584.
- [BETA] Added possibility to record responses to TOML files
via `@_recorder.record(file_path="out.toml")` decorator.
- [BETA] Added possibility to replay responses
(populate registry) from TOML files via
`responses._add_from_file(file_path="out.toml")` method.
- Fix type for the `mock`'s patcher object. See #556
- Fix type annotation for `CallList`
- Add `passthrough` argument to `BaseResponse` object. See #557
- Fix `registries` leak. See #563
- `OriginalResponseShim` is removed. See #585
- Add support for the `loose` version of `json_params_matcher`
via named argument `strict_match`. See #551
- Add lists support as JSON objects in
`json_params_matcher`. See #559
- Added project links to pypi listing.
- `delete`, `get`, `head`, `options`, `patch`,
`post`, `put` shortcuts are now implemented using
`functools.partialmethod`.
- Fix `MaxRetryError` exception. Replace exception by
`RetryError` according to `requests` implementation. See
#572.
- Adjust error message when `Retry` is exhausted. See #580.
- Remove py_old_re_Pattern.patch, because we dont care about
compatibility with pre-SLE15-SP4 any more.
- Add compat-urllib3-2.patch and unbundle-urllib3.patch to make
the package compatible with urllib3 >= 2.0 (still not enough
gh#getsentry/responses#635).
-------------------------------------------------------------------
Fri Apr 21 12:33:09 UTC 2023 - Dirk Müller <dmueller@suse.com>

View File

@ -16,26 +16,33 @@
#
%{?!python_module:%define python_module() python3-%{**}}
%global skip_python2 1
%{?sle15_python_module_pythons}
Name: python-responses
Version: 0.21.0
Version: 0.23.1
Release: 0
Summary: A utility library for mocking out the `requests` Python library
License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/getsentry/responses
Source: https://files.pythonhosted.org/packages/source/r/responses/responses-%{version}.tar.gz
# PATCH-FIX-SLE py_old_re_Pattern.patch mcepl@suse.com
# Make package compatible with SLE-15
Patch0: py_old_re_Pattern.patch
# PATCH-FIX-UPSTREAM unbundle-urllib3.patch bsc#[0-9]+ mcepl@suse.com
# Don't use urllib3 bundled in requests.
Patch0: unbundle-urllib3.patch
# PATCH-{FIX|FEATURE}-{OPENSUSE|SLE|UPSTREAM} name-of-file.patch bsc#[0-9]+ mcepl@suse.com
# this patch makes things totally awesome
Patch1: compat-urllib3-2.patch
# test requirements
BuildRequires: %{python_module cookies}
BuildRequires: %{python_module pytest-localserver}
BuildRequires: %{python_module PyYAML}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest-asyncio}
BuildRequires: %{python_module pytest-httpserver}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests >= 2.0}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module tomli-w}
BuildRequires: %{python_module urllib3 >= 2.0}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-requests >= 2.0
@ -49,25 +56,32 @@ Check https://github.com/getsentry/responses for more information
about the library.
%prep
%autosetup -p1 -n responses-%{version}
%setup -q -n responses-%{version}
%autopatch -p1
%build
export LANG="en_US.UTF8"
export PYTHONIOENCODING="utf_8"
%python_build
%pyproject_wheel
%install
export LANG="en_US.UTF8"
export PYTHONIOENCODING="utf_8"
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
# gh#getsentry/responses#635
skiptests="test_auto_calculate_content_length_doesnt_override_existing_value"
# gh#python/cpython!98095 has not been backported to 3.9
python39_skiptests=" or test_registry_async or test_async_calls"
%pytest -k "not ($skiptests ${$python_skiptests})"
%files %{python_files}
%doc CHANGES README.rst
%license LICENSE
%{python_sitelib}/*
%{python_sitelib}/responses
%{python_sitelib}/responses-%{version}*-info
%changelog

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b82502eb5f09a0289d8e209e7bad71ef3978334f56d09b444253d5ad67bf5253
size 65501

3
responses-0.23.1.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4d9aa9fc888188f0c673eff79a8dadbe2e75b7fe879dc80a221a06e0a68138f
size 72966

87
unbundle-urllib3.patch Normal file
View File

@ -0,0 +1,87 @@
---
responses/__init__.py | 8 ++++----
responses/matchers.py | 2 +-
responses/tests/test_responses.py | 5 +++--
setup.py | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
--- a/responses/__init__.py
+++ b/responses/__init__.py
@@ -42,16 +42,16 @@ except ImportError: # pragma: no cover
from typing import Literal # type: ignore # pragma: no cover
try:
- from requests.packages.urllib3.response import HTTPResponse
+ from urllib3.response import HTTPResponse
except ImportError: # pragma: no cover
from urllib3.response import HTTPResponse # pragma: no cover
try:
- from requests.packages.urllib3.connection import HTTPHeaderDict
+ from urllib3.connection import HTTPHeaderDict
except ImportError: # pragma: no cover
from urllib3.response import HTTPHeaderDict # type: ignore[attr-defined]
try:
- from requests.packages.urllib3.util.url import parse_url
+ from urllib3.util.url import parse_url
except ImportError: # pragma: no cover
from urllib3.util.url import parse_url # pragma: no cover
@@ -1065,7 +1065,7 @@ class RequestsMock(object):
retries = retries or adapter.max_retries
# first validate that current request is eligible to be retried.
- # See ``requests.packages.urllib3.util.retry.Retry`` documentation.
+ # See ``urllib3.util.retry.Retry`` documentation.
if retries.is_retry(
method=response.request.method, status_code=response.status_code # type: ignore[misc]
):
--- a/responses/matchers.py
+++ b/responses/matchers.py
@@ -11,7 +11,7 @@ from urllib.parse import parse_qsl
from urllib.parse import urlparse
from requests import PreparedRequest
-from requests.packages.urllib3.util.url import parse_url
+from urllib3.util.url import parse_url
def _create_key_val_str(input_dict: Union[Dict[Any, Any], Any]) -> str:
--- a/responses/tests/test_responses.py
+++ b/responses/tests/test_responses.py
@@ -13,6 +13,7 @@ from unittest.mock import patch
import pytest
import requests
+import urllib3
from requests.exceptions import ChunkedEncodingError
from requests.exceptions import ConnectionError
from requests.exceptions import HTTPError
@@ -1324,14 +1325,14 @@ def test_content_length_error(monkeypatc
# Type errors here and on 1250 are ignored because the stubs for requests
# are off https://github.com/python/typeshed/blob/f8501d33c737482a829c6db557a0be26895c5941
# /stubs/requests/requests/packages/__init__.pyi#L1
- original_init = getattr(requests.packages.urllib3.HTTPResponse, "__init__") # type: ignore
+ original_init = getattr(urllib3.HTTPResponse, "__init__") # type: ignore
def patched_init(self, *args, **kwargs):
kwargs["enforce_content_length"] = True
original_init(self, *args, **kwargs)
monkeypatch.setattr(
- requests.packages.urllib3.HTTPResponse, "__init__", patched_init # type: ignore
+ urllib3.HTTPResponse, "__init__", patched_init # type: ignore
)
run()
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ setup_requires = []
install_requires = [
"requests>=2.22.0,<3.0",
- "urllib3>=1.25.10",
+ "urllib3>=2.0.0",
"pyyaml",
"types-PyYAML",
"typing_extensions; python_version < '3.8'",