Sync from SUSE:ALP:Source:Standard:1.0 python-httpretty revision 6708dd7c26a466d054d7bbf77849ea8b

This commit is contained in:
Adrian Schröter 2023-10-19 01:00:14 +02:00
commit 303a60cc3e
9 changed files with 585 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

112
453-fix-tests-pytest.patch Normal file
View File

@ -0,0 +1,112 @@
From 299d50c9cb0ba73343d1a88c202e17f6599fde54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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(-)
--- 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_disable
@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_unregister
@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_
@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.
--- 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(co
@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(
@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_recvfro
@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_in
@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(
--- 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")

View File

@ -0,0 +1,99 @@
From 2098d2cfb221995a2523fec3984641f4a15812cc Mon Sep 17 00:00:00 2001
From: Sarah Julia Kriesch <sarah-julia.kriesch@gmx.de>
Date: Thu, 27 Oct 2022 08:55:50 +0200
Subject: [PATCH 1/2] Fix build issues based on tests with the requirement of 2
miliseconds #459
Signed-off-by: Sarah Julia Kriesch <sarah-julia.kriesch@gmx.de>
---
tests/functional/test_httplib2.py | 9 +++------
tests/functional/test_urllib2.py | 7 ++-----
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/tests/functional/test_httplib2.py b/tests/functional/test_httplib2.py
index c913d8a8..6cb27e1b 100644
--- a/tests/functional/test_httplib2.py
+++ b/tests/functional/test_httplib2.py
@@ -112,8 +112,7 @@ def test_httpretty_should_allow_adding_and_overwritting_httplib2():
@httprettified
-@within(two=miliseconds)
-def test_httpretty_should_allow_forcing_headers_httplib2(now):
+def test_httpretty_should_allow_forcing_headers_httplib2():
"HTTPretty should allow forcing headers with httplib2"
HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo",
@@ -165,8 +164,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2():
@httprettified
-@within(two=miliseconds)
-def test_rotating_responses_with_httplib2(now):
+def test_rotating_responses_with_httplib2():
"HTTPretty should support rotating responses with httplib2"
HTTPretty.register_uri(
@@ -248,8 +246,7 @@ def test_can_inspect_last_request_with_ssl(now):
@httprettified
-@within(two=miliseconds)
-def test_httpretty_ignores_querystrings_from_registered_uri(now):
+def test_httpretty_ignores_querystrings_from_registered_uri():
"Registering URIs with query string cause them to be ignored"
HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/?id=123",
diff --git a/tests/functional/test_urllib2.py b/tests/functional/test_urllib2.py
index 9c8ff39f..4cba7253 100644
--- a/tests/functional/test_urllib2.py
+++ b/tests/functional/test_urllib2.py
@@ -127,7 +127,6 @@ def test_httpretty_should_allow_adding_and_overwritting_urllib2():
@httprettified
-@within(two=miliseconds)
def test_httpretty_should_allow_forcing_headers_urllib2():
"HTTPretty should allow forcing headers with urllib2"
@@ -177,8 +176,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2():
@httprettified
-@within(two=miliseconds)
-def test_httpretty_should_support_a_list_of_successive_responses_urllib2(now):
+def test_httpretty_should_support_a_list_of_successive_responses_urllib2():
("HTTPretty should support adding a list of successive "
"responses with urllib2")
@@ -285,8 +283,7 @@ def test_httpretty_ignores_querystrings_from_registered_uri():
@httprettified
-@within(two=miliseconds)
-def test_callback_response(now):
+def test_callback_response():
("HTTPretty should call a callback function to be set as the body with"
" urllib2")
From 063a58bb8a7c2f213c07b343a5e1fe48944f1f08 Mon Sep 17 00:00:00 2001
From: Sarah Julia Kriesch <sarah-julia.kriesch@gmx.de>
Date: Thu, 27 Oct 2022 09:20:40 +0200
Subject: [PATCH 2/2] Fix asertion error with 0,24 instead of 0,2 #459
Signed-off-by: Sarah Julia Kriesch <sarah-julia.kriesch@gmx.de>
---
tests/bugfixes/nosetests/test_430_respect_timeout.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/bugfixes/nosetests/test_430_respect_timeout.py b/tests/bugfixes/nosetests/test_430_respect_timeout.py
index f21a5468..ed5866b9 100644
--- a/tests/bugfixes/nosetests/test_430_respect_timeout.py
+++ b/tests/bugfixes/nosetests/test_430_respect_timeout.py
@@ -51,4 +51,4 @@ def my_callback(request, url, headers):
# And the total execution time should be less than 0.2 seconds
event.set()
total_time = time.time() - started_at
- total_time.should.be.lower_than(0.2)
+ total_time.should.be.lower_than(0.24)

10
double-slash-paths.patch Normal file
View File

@ -0,0 +1,10 @@
Index: httpretty-1.1.4/tests/functional/test_requests.py
===================================================================
--- httpretty-1.1.4.orig/tests/functional/test_requests.py
+++ httpretty-1.1.4/tests/functional/test_requests.py
@@ -946,4 +946,4 @@ def test_httpretty_should_handle_paths_s
response = requests.get('http://example.com//foo')
expect(response.text).to.equal('Find the best foo')
expect(HTTPretty.last_request.method).to.equal('GET')
- expect(HTTPretty.last_request.path).to.equal('//foo')
+ expect(HTTPretty.last_request.path).to.be.within(['//foo', '/foo'])

BIN
httpretty-1.1.4.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

206
python-httpretty.changes Normal file
View File

@ -0,0 +1,206 @@
-------------------------------------------------------------------
Tue Jun 13 08:37:50 UTC 2023 - ecsos <ecsos@opensuse.org>
- Add %{?sle15_python_module_pythons}
-------------------------------------------------------------------
Tue May 16 07:35:42 UTC 2023 - Dirk Müller <dmueller@suse.com>
- skip failing testsuite tests after requests update
-------------------------------------------------------------------
Thu Mar 30 04:21:14 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch relax-test-callback-response.patch:
* Relax timeout for test_callback_response (bsc#1209571)
-------------------------------------------------------------------
Thu Oct 27 16:52:32 UTC 2022 - Sarah Kriesch <sarah.kriesch@opensuse.org>
- Add patch 460-miliseconds_tests.patch (gh#gabrielfalcao/HTTPretty#460):
* Correct tests for s390x and aarch64 because of timeout failures
after 2 miliseconds
-------------------------------------------------------------------
Sun Aug 8 09:17:40 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Fix test suite:
* Remove nose idioms
* Remove outdated test skips
-------------------------------------------------------------------
Mon Aug 8 02:53:55 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch double-slash-paths.patch:
* http.request may replace // with /, handle that in the testcase.
-------------------------------------------------------------------
Sat Aug 6 17:32:34 UTC 2022 - Matej Cepl <mcepl@suse.com>
- Add 453-fix-tests-pytest.patch (gh#gabrielfalcao/HTTPretty#449)
to make tests compatible with pytest.
-------------------------------------------------------------------
Thu May 5 07:53:54 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch remove-mock.patch:
* Use unittest.mock in the functional tests.
-------------------------------------------------------------------
Sat Mar 12 05:50:55 UTC 2022 - Arun Persaud <arun@gmx.de>
- specfile:
* update copyright year
- update to version 1.1.4:
* Bugfix: #435 Fallback to WARNING when logging.getLogger().level is
None.
- changes from version 1.1.3:
* Bugfix: #430 Respect socket timeout.
- changes from version 1.1.2:
* Bugfix: #426 Segmentation fault when running against a large
amount of tests with pytest --mypy.
- changes from version 1.1.1:
* Bugfix: httpretty.disable() injects pyopenssl into
:py:mod:`urllib3` even if it originally wasn't #417
* Bugfix: "Incompatibility with boto3 S3 put_object" #416
* Bugfix: "Regular expression for URL -> TypeError: wrap_socket()
missing 1 required" #413
* Bugfix: "Making requests to non-stadard port throws TimeoutError
"#387
- changes from version 1.1.0:
* Feature: Display mismatched URL within UnmockedError whenever
possible. #388
* Feature: Display mismatched URL via logging. #419
* Add new properties to :py:class:`httpretty.core.HTTPrettyRequest`
(protocol, host, url, path, method).
-------------------------------------------------------------------
Mon Mar 22 20:00:53 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Updater to 1.0.5
* Bugfix: Support socket.socketpair() . #402
* Bugfix: Prevent exceptions from re-applying monkey patches.
#406
- Release 1.0.4
* Python 3.8 and 3.9 support. #407
-------------------------------------------------------------------
Mon Dec 14 15:44:23 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- Update to 1.0.3
* Fix compatibility with urllib3>=1.26. #410
-------------------------------------------------------------------
Sun Aug 16 11:36:11 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Replace nose with nose2
-------------------------------------------------------------------
Wed Aug 12 12:24:09 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- avoid reading DNS resolver settings
gh#gabrielfalcao/HTTPretty#405
- remove unnecessary test packages
-------------------------------------------------------------------
Thu Apr 9 11:25:31 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Update to 1.0.2
* Drop Python 2 support.
* Fix usage with redis and improve overall real-socket passthrough.
* Fix TypeError: wrap_socket() missing 1 required positional argument: 'sock'.
* Fix simple typo: neighter -> neither.
* Updated documentation for register_uri concerning using ports.
* Clarify relation between ``enabled`` and ``httprettized`` in API docs.
* Align signature with builtin socket.
-------------------------------------------------------------------
Mon Jan 7 08:22:15 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Version update to 0.9.6:
* Many fixes all around
* Support for python 3.7
- Make sure we really run the tests
-------------------------------------------------------------------
Tue Dec 4 12:48:59 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Remove superfluous devel dependency for noarch package
-------------------------------------------------------------------
Sat Aug 26 13:35:45 UTC 2017 - jengelh@inai.de
- Fix spello in description. Move summary extent to description.
-------------------------------------------------------------------
Tue Aug 15 20:13:58 UTC 2017 - daniel.molkentin@suse.com
- Update to 0.8.14
- Converted to singlespec
- Remove legacy macros
- Ran spec-cleaner
-------------------------------------------------------------------
Sun Mar 13 21:05:33 UTC 2016 - dmueller@suse.com
- add copying
-------------------------------------------------------------------
Wed Apr 22 08:43:41 UTC 2015 - mcihar@suse.cz
- Update to 0.8.8:
* many changes
-------------------------------------------------------------------
Wed Jul 23 10:58:55 UTC 2014 - mcihar@suse.cz
- Upgrate to 0.8.3:
* various minor fixes
-------------------------------------------------------------------
Mon Feb 17 12:50:39 UTC 2014 - speilicke@suse.com
- Drop old tarball
-------------------------------------------------------------------
Mon Feb 17 10:02:32 UTC 2014 - dmueller@suse.com
- update to 0.8.0:
* This new version brings Python 3 support, leaner requirements
- remove deps-cleanup.diff
-------------------------------------------------------------------
Fri Jan 17 10:22:22 UTC 2014 - speilicke@suse.com
- Update to version 0.7.1:
+ Bug fix: POST requests being called twice #100
- Rebased deps-cleanup.diff
-------------------------------------------------------------------
Mon Oct 28 13:09:26 UTC 2013 - speilicke@suse.com
- Don't install global "tests" module into python_sitelib
-------------------------------------------------------------------
Mon Oct 21 12:22:31 UTC 2013 - dmueller@suse.com
- update to 0.7.0:
* Refactored core.py and increased its unit test coverage to 80%.
HTTPretty is slightly more robust now
-------------------------------------------------------------------
Thu Sep 26 13:30:37 UTC 2013 - dmueller@suse.com
- update to 0.6.4:
* Add a way to match the querystrings
-------------------------------------------------------------------
Mon Sep 2 18:19:38 UTC 2013 - dmueller@suse.com
- Initial package (0.6.3)

85
python-httpretty.spec Normal file
View File

@ -0,0 +1,85 @@
#
# spec file for package python-httpretty
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
Name: python-httpretty
Version: 1.1.4
Release: 0
Summary: HTTP client mocking tool for Python
License: MIT
URL: https://github.com/gabrielfalcao/HTTPretty
Source: https://files.pythonhosted.org/packages/source/h/httpretty/httpretty-%{version}.tar.gz
Patch0: remove-mock.patch
# PATCH-FIX-UPSTREAM 453-fix-tests-pytest.patch gh#gabrielfalcao/HTTPretty#449 mcepl@suse.com
# Make tests compatible with pytest
Patch1: 453-fix-tests-pytest.patch
# PATCH-FIX-OPENSUSE test_double_slash may be replaced with / from stdlib
# gh#gabrielfalcao/HTTPretty#457
Patch2: double-slash-paths.patch
#PATCH-FIX-UPSTREAM 460-fix-tests-two-miliseconds
Patch3: 460-miliseconds_tests.patch
# PATCH-FIX-OPENSUSE Relax the time for one test case from 2ms to 3ms.
Patch4: relax-test-callback-response.patch
BuildRequires: %{python_module boto3}
BuildRequires: %{python_module eventlet}
BuildRequires: %{python_module fakeredis}
BuildRequires: %{python_module freezegun}
BuildRequires: %{python_module httplib2}
BuildRequires: %{python_module pytest-httpserver}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module sure}
BuildRequires: %{python_module tornado}
BuildRequires: %{python_module urllib3 with %python-urllib3 < 2}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
%description
This library allows mocking of HTTP protocol based
unit tests.
It is similar to Ruby's FakeWeb.
%prep
%autosetup -p1 -n httpretty-%{version}
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# gh#gabrielfalcao/HTTPretty#405
export EVENTLET_NO_GREENDNS=yes
# needs internet connection to httpbin.org
donttest="test_http_passthrough or test_https_passthrough"
# flaky (too slow) on obs
donttest="$donttest or test_httpretty_should_allow_forcing_headers_urllib2 or test_httpretty_should_allow_registering_regexes_with_streaming_responses"
%pytest -k "not (${donttest})"
%files %{python_files}
%license COPYING
%doc README.rst
%{python_sitelib}/httpretty
%{python_sitelib}/httpretty-%{version}*-info
%changelog

View File

@ -0,0 +1,13 @@
Index: httpretty-1.1.4/tests/functional/test_requests.py
===================================================================
--- httpretty-1.1.4.orig/tests/functional/test_requests.py
+++ httpretty-1.1.4/tests/functional/test_requests.py
@@ -456,7 +456,7 @@ def test_multipart():
@httprettified
-@within(two=miliseconds)
+@within(three=miliseconds)
def test_callback_response(now):
("HTTPretty should call a callback function and set its return value as the body of the response"
" requests")

34
remove-mock.patch Normal file
View File

@ -0,0 +1,34 @@
Index: httpretty-1.1.4/tests/functional/test_fakesocket.py
===================================================================
--- httpretty-1.1.4.orig/tests/functional/test_fakesocket.py
+++ httpretty-1.1.4/tests/functional/test_fakesocket.py
@@ -28,7 +28,10 @@
import functools
import socket
-import mock
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
class FakeSocket(socket.socket):
@@ -60,7 +63,7 @@ def recv(flag, size):
recv = functools.partial(recv, fake_socket_interupter_flag)
-@mock.patch('httpretty.old_socket', new=FakeSocket)
+@patch('httpretty.old_socket', new=FakeSocket)
def _test_shorten_response():
u"HTTPretty shouldn't try to read from server when communication is over"
from sure import expect
@@ -68,7 +71,7 @@ def _test_shorten_response():
fakesocket = httpretty.fakesock.socket(socket.AF_INET,
socket.SOCK_STREAM)
- with mock.patch.object(fakesocket.truesock, 'recv', recv):
+ with patch.object(fakesocket.truesock, 'recv', recv):
fakesocket.connect(('localhost', 80))
fakesocket._true_sendall('WHATEVER')
expect(fakesocket.fd.read()).to.equal(