-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate requests in latest_requests() if there are chunks #425
Comments
These duplicate requests broke my CI. Pinning |
I also came looking for this because of a broken CI. |
Oh gee, thanks @ChipmunkV for the solution. I'll get a new release out soon and will ping you folks once it's done. |
@ChipmunkV, @Gidgidonihah , @ThiefMaster I'm attempting to write a functional test to reproduce the bug. |
FYI, I cloned master after merge and tested it, and my tests are still failing with the wrong number of requests in latest_requests. I don't yet have a MWE example, but I would love to get one worked up. |
@Gidgidonihah I'd love to work with you in a solution for this, I just want to make sure there is an automated test to reproduce the issue. I tried running the tests from My main concern with I take automated testing very seriously and want to make sure that whatever the case is, we can find the best possible solution for HTTPretty and ensure that your tests pass correctly (without false-positives). How do you think I should proceed with this issue? |
The issue title suggests that the problem occurs "if there are chunks". I suppose this is a problem with chunked requests, is that the case for everyone here? |
Feel free to send a PR against my repo that reverts this commit and installs httpretty from git. That way you don't need to setup the somewhat complex environment locally but still see if the error happens or not. Alternatively, if you point me to the branch from which I can install the (potentially) fixed version I can give it a try locally. |
Thanks @ThiefMaster, I already merged 0eb4b16 and released the changes in version |
@Gidgidonihah if you could also test your code against 1.1.3 that would be great. |
@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. |
@gabrielfalcao Here's a gist for a MWE. Using a python 3.9.5 virtualenv, just ran: pip install -r requirements.txt
python -m unittest |
@gabrielfalcao It looks like there's another thing duplicating requests (I think). I've created a unit test within the repo that fails. I narrowed it down to a POST that has data. Unless it's a preflight request that's being stored? That would explain the body being 0, though I'd expect the method to be OPTIONS and not POST. |
@gabrielfalcao I can confirm that it only appears to impact POST requests as @tim-schilling suggested: import httpretty
import requests
httpretty.enable()
httpretty.register_uri(method=httpretty.POST, uri="https://example.com/foo")
requests.post("https://example.com/foo", data="bar")
len(httpretty.latest_requests())
# returns 2
httpretty.reset()
httpretty.register_uri(method=httpretty.GET, uri="https://example.com/foo")
requests.get("https://example.com/foo")
len(httpretty.latest_requests())
# returns 1 |
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. |
A release containing this fix would be great! |
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 ( import httpretty
import urllib.request as request
class TestHTTpretty:
@httpretty.activate(verbose=True, allow_net_connect=False)
def run(self, method, data=None):
url = 'https://example.com/foo'
httpretty.register_uri(method=method, uri=url)
req = request.Request(url=url, method=method, data=data)
request.urlopen(req)
assert len(httpretty.latest_requests()) == 1
# the first eight tests with empty request bodies succeed
def test_get(self):
self.run(httpretty.GET)
def test_head(self):
self.run(httpretty.HEAD)
def test_connect(self):
self.run(httpretty.CONNECT)
def test_options(self):
self.run(httpretty.OPTIONS)
def test_post_empty(self):
self.run(httpretty.POST)
def test_put_empty(self):
self.run(httpretty.PUT)
def test_delete_empty(self):
self.run(httpretty.DELETE)
def test_patch_empty(self):
self.run(httpretty.PATCH)
# the following four tests with populated request bodies fail
def test_post_with_data(self):
self.run(httpretty.POST, b'lorem ipsum')
def test_put_with_data(self):
self.run(httpretty.PUT, b'lorem ipsum')
def test_delete_with_data(self):
self.run(httpretty.DELETE, b'lorem ipsum')
def test_patch_with_data(self):
self.run(httpretty.PATCH, b'lorem ipsum') Output:
|
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? |
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: gabrielfalcao/HTTPretty#425 Include setuptools because is a dependency of uri but it is not explicit and latests version of Poetry removes setuptools. Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
+1 for a 1.1.5 release |
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: gabrielfalcao/HTTPretty#425 Include setuptools because is a dependency of uri but it is not explicit and latests version of Poetry removes setuptools. Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
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: gabrielfalcao/HTTPretty#425 Include setuptools because is a dependency of uri but it is not explicit and latests version of Poetry removes setuptools. Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
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: gabrielfalcao/HTTPretty#425 Include setuptools because is a dependency of uri but it is not explicit and latests version of Poetry removes setuptools. Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
@gabrielfalcao Can we please get an 1.1.5 release containing this fix? |
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
|
Hi folks, |
Hi @gabrielfalcao, This is a friendly reminder; I hope you'll find some time to make a new release :) Thank you |
Problem exists in httpretty==1.1.4 @gabrielfalcao thanks for your great effort, it is appreciated! |
Due to a bug in httpretty v1.1.0, we need to keep it pinned. Stop dependabot trying to upgrade it. gabrielfalcao/HTTPretty#425
Was fine with 1.0.5, does duplicates in 1.1.0.
The change: b6161ce#r50812634
httpretty.historify_request()
is called multiple times for the same request.From here:
And here:
The text was updated successfully, but these errors were encountered: