HTTPretty: Duplicate requests in latest_requests() if there are chunks
Was 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
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 14
- Comments: 24 (9 by maintainers)
Commits related to this issue
- Improve debugging experience via `UnmockedError` and logging (#419) Feature: Display mismatched URL within UnmockedError whenever possible. Closes #388 Feature: Display mismatched URL via logging.... — committed to gabrielfalcao/HTTPretty by gabrielfalcao 3 years ago
- Pin httpretty (fix ravem tests) See gabrielfalcao/HTTPretty#425 — committed to indico/indico-plugins-cern by ThiefMaster 3 years ago
- attempt to reproduce #425 — committed to gabrielfalcao/HTTPretty by gabrielfalcao 3 years ago
- Fix #425 (#429) * attempt to reproduce #425 * 💅 — committed to gabrielfalcao/HTTPretty by gabrielfalcao 3 years ago
- Update package dependencies This commit updates some packages to be same as in other GrimoireLab repsoitories. httpretty>1.1 contains a bug which causing fail of our test. For more info see: gabriel... — committed to jjmerchante/grimoirelab-sortinghat by jjmerchante 2 years ago
- Update package dependencies This commit updates some packages to be same as in other GrimoireLab repsoitories. httpretty>1.1 contains a bug which causing fail of our test. For more info see: gabriel... — committed to jjmerchante/grimoirelab-sortinghat by jjmerchante 2 years ago
- Update package dependencies This commit updates some packages to be same as in other GrimoireLab repsoitories. httpretty>1.1 contains a bug which causing fail of our test. For more info see: gabriel... — committed to jjmerchante/grimoirelab-sortinghat by jjmerchante 2 years ago
- Update package dependencies This commit updates some packages to be same as in other GrimoireLab repsoitories. httpretty>1.1 contains a bug which causing fail of our test. For more info see: gabriel... — committed to jjmerchante/grimoirelab-sortinghat by jjmerchante 2 years ago
+1 for a 1.1.5 release
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:
Hi @gabrielfalcao,
This is a friendly reminder; I hope you’ll find some time to make a new release 😃
Thank you
Hi folks, I presently find myself somewhat able to work on this issue. I’ll do what I can to make a release. Thanks for your patience so far.
Thanks @daveygit2050 I’ll incorporate this snippet into a new test case to reproduce the issue as soon as I can manage. Unfortunately I might not be able to attend to this until next week but I’ll keep yall posted.
These duplicate requests broke my CI. Pinning
httpretty<1.1
is a workaround but a fix would be appreciated.Problem exists in httpretty==1.1.4 httpretty==1.0.5 works as a workaround
@gabrielfalcao thanks for your great effort, it is appreciated!
Salutations all,
my macbook got damaged and I’m quite a bit limited at present due to the time taken for the new parts to arrive. I plan on applying the patch and resolve the situation as soon as the universe collaborates. Please hang in there and I’ll report back as soon as humanely possible.
Kind regards, Gabriel
@gabrielfalcao Can we please get an 1.1.5 release containing this fix?
@gabrielfalcao Same result for me. Thanks for getting on this quickly. I’ll try to get an MWE together at the end of my sprint.