Compare commits
10 Commits
548804b481
...
f27bb1c4bd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f27bb1c4bd | ||
|
|
f4410d2f44 | ||
|
|
392569720e | ||
|
|
3d580028a3 | ||
|
|
154cc001f9 | ||
|
|
fdf547708a | ||
|
|
66749cb86e | ||
|
|
544005cad4 | ||
|
|
6c726e39ec | ||
|
|
23cc1e7704 |
@ -0,0 +1,76 @@
|
|||||||
|
From c255165a86bef7f894c3a446b41d0b3379c5c2be Mon Sep 17 00:00:00 2001
|
||||||
|
From: Eugene Morozov <jmv@emorozov.net>
|
||||||
|
Date: Mon, 13 Sep 2021 20:30:00 +0300
|
||||||
|
Subject: [PATCH] Fixes #425. (#436)
|
||||||
|
|
||||||
|
by @emorozov
|
||||||
|
---
|
||||||
|
httpretty/core.py | 6 +++---
|
||||||
|
tests/functional/test_requests.py | 6 +++---
|
||||||
|
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/httpretty/core.py b/httpretty/core.py
|
||||||
|
index 19715e0..6968645 100644
|
||||||
|
--- a/httpretty/core.py
|
||||||
|
+++ b/httpretty/core.py
|
||||||
|
@@ -796,7 +796,7 @@ class fakesock(object):
|
||||||
|
else:
|
||||||
|
self._entry.request.body += body
|
||||||
|
|
||||||
|
- httpretty.historify_request(headers, body, sock=self)
|
||||||
|
+ httpretty.historify_request(headers, body, sock=self, append=False)
|
||||||
|
return
|
||||||
|
|
||||||
|
if path[:2] == '//':
|
||||||
|
@@ -1602,7 +1602,7 @@ class httpretty(HttpBaseClass):
|
||||||
|
__internals__.cleanup_sockets()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
- def historify_request(cls, headers, body='', sock=None):
|
||||||
|
+ def historify_request(cls, headers, body='', sock=None, append=True):
|
||||||
|
"""appends request to a list for later retrieval
|
||||||
|
|
||||||
|
.. testcode::
|
||||||
|
@@ -1618,7 +1618,7 @@ class httpretty(HttpBaseClass):
|
||||||
|
request = HTTPrettyRequest(headers, body, sock=sock)
|
||||||
|
cls.last_request = request
|
||||||
|
|
||||||
|
- if request not in cls.latest_requests:
|
||||||
|
+ if append or not cls.latest_requests:
|
||||||
|
cls.latest_requests.append(request)
|
||||||
|
else:
|
||||||
|
cls.latest_requests[-1] = request
|
||||||
|
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py
|
||||||
|
index 752428b..55aa109 100644
|
||||||
|
--- a/tests/functional/test_requests.py
|
||||||
|
+++ b/tests/functional/test_requests.py
|
||||||
|
@@ -407,7 +407,7 @@ def test_multiline():
|
||||||
|
expect(HTTPretty.last_request.body).to.equal(data)
|
||||||
|
expect(HTTPretty.last_request.headers['content-length']).to.equal('37')
|
||||||
|
expect(HTTPretty.last_request.headers['content-type']).to.equal('application/x-www-form-urlencoded; charset=utf-8')
|
||||||
|
- expect(len(HTTPretty.latest_requests)).to.equal(2)
|
||||||
|
+ expect(len(HTTPretty.latest_requests)).to.equal(1)
|
||||||
|
|
||||||
|
|
||||||
|
@httprettified
|
||||||
|
@@ -431,7 +431,7 @@ def test_octet_stream():
|
||||||
|
expect(HTTPretty.last_request.body).to.equal(data)
|
||||||
|
expect(HTTPretty.last_request.headers['content-length']).to.equal('4')
|
||||||
|
expect(HTTPretty.last_request.headers['content-type']).to.equal('application/octet-stream')
|
||||||
|
- expect(len(HTTPretty.latest_requests)).to.equal(2)
|
||||||
|
+ expect(len(HTTPretty.latest_requests)).to.equal(1)
|
||||||
|
|
||||||
|
|
||||||
|
@httprettified
|
||||||
|
@@ -452,7 +452,7 @@ def test_multipart():
|
||||||
|
expect(HTTPretty.last_request.body).to.equal(data)
|
||||||
|
expect(HTTPretty.last_request.headers['content-length']).to.equal('495')
|
||||||
|
expect(HTTPretty.last_request.headers['content-type']).to.equal('multipart/form-data; boundary=xXXxXXyYYzzz')
|
||||||
|
- expect(len(HTTPretty.latest_requests)).to.equal(2)
|
||||||
|
+ expect(len(HTTPretty.latest_requests)).to.equal(1)
|
||||||
|
|
||||||
|
|
||||||
|
@httprettified
|
||||||
|
--
|
||||||
|
2.39.0.windows.2
|
||||||
|
|
||||||
37
add-support-for-Misdirected-Request.patch
Normal file
37
add-support-for-Misdirected-Request.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 20c02cdb77bd6c9827625a68c1a1af339c50b819 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Lu=C3=ADs=20Soares?= <lsoares@gmail.com>
|
||||||
|
Date: Thu, 8 Sep 2022 10:12:46 +0100
|
||||||
|
Subject: [PATCH] add support for 421: "Misdirected Request"
|
||||||
|
|
||||||
|
---
|
||||||
|
httpretty/http.py | 1 +
|
||||||
|
tests/unit/test_httpretty.py | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/httpretty/http.py b/httpretty/http.py
|
||||||
|
index 87ceca9..0f75935 100644
|
||||||
|
--- a/httpretty/http.py
|
||||||
|
+++ b/httpretty/http.py
|
||||||
|
@@ -73,6 +73,7 @@ STATUSES = {
|
||||||
|
417: "Expectation Failed",
|
||||||
|
418: "I'm a teapot",
|
||||||
|
420: "Enhance Your Calm",
|
||||||
|
+ 421: "Misdirected Request",
|
||||||
|
422: "Unprocessable Entity",
|
||||||
|
423: "Locked",
|
||||||
|
424: "Failed Dependency",
|
||||||
|
diff --git a/tests/unit/test_httpretty.py b/tests/unit/test_httpretty.py
|
||||||
|
index 017b290..89b2abf 100644
|
||||||
|
--- a/tests/unit/test_httpretty.py
|
||||||
|
+++ b/tests/unit/test_httpretty.py
|
||||||
|
@@ -117,6 +117,7 @@ def test_status_codes():
|
||||||
|
417: "Expectation Failed",
|
||||||
|
418: "I'm a teapot",
|
||||||
|
420: "Enhance Your Calm",
|
||||||
|
+ 421: "Misdirected Request",
|
||||||
|
422: "Unprocessable Entity",
|
||||||
|
423: "Locked",
|
||||||
|
424: "Failed Dependency",
|
||||||
|
--
|
||||||
|
2.39.0.windows.2
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: python-httpretty
|
Name: python-httpretty
|
||||||
Version: 1.1.4
|
Version: 1.1.4
|
||||||
Release: 2
|
Release: 7
|
||||||
Summary: HTTP Client mocking tool for Python
|
Summary: HTTP Client mocking tool for Python
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://pypi.org/project/httpretty/
|
URL: https://pypi.org/project/httpretty/
|
||||||
@ -8,6 +8,10 @@ Source0: https://files.pythonhosted.org/packages/source/h/httpretty/httpr
|
|||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
|
Patch0000: test_handle_slashes.patch
|
||||||
|
Patch0001: Duplicate-requests-in-latest_requests-if-there-are-chunks.patch
|
||||||
|
Patch0002: add-support-for-Misdirected-Request.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
HTTP Client mocking tool for Python.Provides a full fake TCP socket module.
|
HTTP Client mocking tool for Python.Provides a full fake TCP socket module.
|
||||||
|
|
||||||
@ -38,6 +42,10 @@ export EVENTLET_NO_GREENDNS=yes
|
|||||||
sed -Ei 's/(test_https?_passthrough)/_\1/' tests/functional/test_passthrough.py
|
sed -Ei 's/(test_https?_passthrough)/_\1/' tests/functional/test_passthrough.py
|
||||||
sed -Ei 's/(test_streaming_responses)/_\1/' tests/functional/test_requests.py
|
sed -Ei 's/(test_streaming_responses)/_\1/' tests/functional/test_requests.py
|
||||||
sed -Ei 's/(test_fakesock_socket_sendall_with_body_data_with_chunked_entry)/_\1/' tests/unit/test_core.py
|
sed -Ei 's/(test_fakesock_socket_sendall_with_body_data_with_chunked_entry)/_\1/' tests/unit/test_core.py
|
||||||
|
sed -Ei 's/(test_httpretty_should_allow_registering_regexes_with_streaming_responses)/_\1/' tests/functional/test_requests.py
|
||||||
|
%if "%_arch" == "riscv64"
|
||||||
|
sed -Ei 's/two=miliseconds/ten=miliseconds/g' tests/functional/test_{urllib2,httplib2}.py
|
||||||
|
%endif
|
||||||
LANG=en_US.UTF-8 %{__python3} -m nose2 -v
|
LANG=en_US.UTF-8 %{__python3} -m nose2 -v
|
||||||
|
|
||||||
%files -n python3-httpretty
|
%files -n python3-httpretty
|
||||||
@ -47,6 +55,21 @@ LANG=en_US.UTF-8 %{__python3} -m nose2 -v
|
|||||||
%{python3_sitelib}/httpretty-%{version}-py%{python3_version}.egg-info
|
%{python3_sitelib}/httpretty-%{version}-py%{python3_version}.egg-info
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 4 2024 laokz <zhangkai@iscas.ac.cn> - 1.1.4-7
|
||||||
|
- riscv64: increase tests timeout
|
||||||
|
|
||||||
|
* Wed Aug 2 2023 liyanan <thistleslyn@163.com> - 1.1.4-6
|
||||||
|
- skip failing testsuite tests after requests update
|
||||||
|
|
||||||
|
* Mon Jan 9 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.1.4-5
|
||||||
|
- add support for Misdirected Request
|
||||||
|
|
||||||
|
* Sat Jan 7 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.1.4-4
|
||||||
|
- Fix Duplicate requests in latest_requests if there are chunks
|
||||||
|
|
||||||
|
* Fri Nov 25 2022 xu_ping <xuping33@h-partners.com> - 1.1.4-3
|
||||||
|
- Fix test_httpretty_should_handle_paths_starting_with_two_slashes fail.
|
||||||
|
|
||||||
* Wed Aug 3 2022 kkz <zhaoshuang@uniontech.com> - 1.1.4-2
|
* Wed Aug 3 2022 kkz <zhaoshuang@uniontech.com> - 1.1.4-2
|
||||||
- Remove unnecessary buildrequires
|
- Remove unnecessary buildrequires
|
||||||
|
|
||||||
|
|||||||
9
test_handle_slashes.patch
Normal file
9
test_handle_slashes.patch
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
diff -Nur a/tests/functional/test_requests.py b/tests/functional/test_requests.py
|
||||||
|
--- a/tests/functional/test_requests.py 2021-05-14 09:02:06.000000000 +0800
|
||||||
|
+++ b/tests/functional/test_requests.py 2022-08-27 15:44:21.935602830 +0800
|
||||||
|
@@ -946,4 +946,4 @@
|
||||||
|
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.equal('/foo')
|
||||||
Loading…
x
Reference in New Issue
Block a user