Duplicate requests in latest_requests() if there are chunks
See original GitHub issueWas fine with 1.0.5, does duplicates in 1.1.0.
The change: https://github.com/gabrielfalcao/HTTPretty/commit/b6161cebfdaf5f68ef49526e51b460b8e0c0c6c2#r50812634
- cls.latest_requests[-1] = request
+ pos = cls.latest_requests.index(request)
+ cls.latest_requests[pos] = request
httpretty.historify_request()
is called multiple times for the same request.
From here:
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1081, in _send_output
self.send(chunk)
File "/usr/lib/python3.6/http/client.py", line 1002, in send
self.sock.sendall(data)
File "/usr/local/lib/python3.6/dist-packages/httpretty/core.py", line 683, in sendall
And here:
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests-2.25.1-py3.6.egg/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 1002, in send
self.sock.sendall(data)
File "/usr/local/lib/python3.6/dist-packages/httpretty/core.py", line 699, in sendall
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Making multiple requests with Alamofire depending on array ...
The issue is that you call completion(.success(data.data)) on each chunck. You want instead of keep an array of data and append them: let ......
Read more >Advanced Usage — Requests 2.28.1 documentation
Chunk -Encoded Requests iter_content() . In an ideal situation you'll have set stream=True on the request, in which case you can iterate chunk-by-chunk...
Read more >Controlling multiple HTTP requests with RxJS - esveo
All of the observables within one chunk will be run in serial ( concat + toArray ) and combined into one resulting observable...
Read more >Combine multiple requests in one HTTP call using JSON ...
The status code on a batch response is typically 200 or 400 . If the batch request itself is malformed, the status code...
Read more >Aggregate Multiple API Requests with Promise.all()
It returns an array containing each promise resolution in the same order. If any of the promises in Promise.all() is rejected, the promise ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am dealing with the exact same issue. Looks like there was a fix merged into the master. As @ThiefMaster was pointing out, @gabrielfalcao would it be possible to deploy a new release?
Thank you for creating a tool that helps improve automated tests! 🤗
I recently encountered this issue and wanted to add more info. In my testing, this applies to any requests (
POST
,PUT
,DELETE
, and/orPATCH
) when they contain a request body. Below is a test file that demonstrates this behavior. (I did not include tests with request bodies for HTTP methods which do not allow request bodies (GET
,HEAD
,CONNECT
, andOPTIONS
), however these also demonstrate the behavior when a request body is provided.)Output: