fix Duplicate requests in latest_requests if there are chunks
Signed-off-by: zhangliangpengkun <zhangliangpengkun@xfusion.com>
This commit is contained in:
parent
6c726e39ec
commit
544005cad4
@ -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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: python-httpretty
|
||||
Version: 1.1.4
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: HTTP Client mocking tool for Python
|
||||
License: MIT
|
||||
URL: https://pypi.org/project/httpretty/
|
||||
@ -9,6 +9,7 @@ Source0: https://files.pythonhosted.org/packages/source/h/httpretty/httpr
|
||||
BuildArch: noarch
|
||||
|
||||
Patch0000: test_handle_slashes.patch
|
||||
Patch0001: Duplicate-requests-in-latest_requests-if-there-are-chunks.patch
|
||||
|
||||
%description
|
||||
HTTP Client mocking tool for Python.Provides a full fake TCP socket module.
|
||||
@ -49,6 +50,9 @@ LANG=en_US.UTF-8 %{__python3} -m nose2 -v
|
||||
%{python3_sitelib}/httpretty-%{version}-py%{python3_version}.egg-info
|
||||
|
||||
%changelog
|
||||
* 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.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user