Improve catch_response feature (was previous: Remove catch_response feature from HttpBrowser)
See original GitHub issueTo me - even though I was in favor of it when we implemented it - the catch_response feature is slightly odd, and I’m not sure it should be a feature in Locust. A web app should not return 200 OK if the request in fact failed. I also think it would be a mistake to keep locust features that are focused toward detecting errors in the app that should have been spotted by the app’s own unit/integration tests. Simply because it’s better to focus on one thing (in our case load testing and user simulation) and kick ass at that 😃.
If someone is wandering I’m talking about the following syntax:
from locust import ResponseError
with self.client.get("/inbox", catch_response=True) as response:
if response.data == "fail":
raise ResponseError("Request failed")
Part of the reason I’m bringing this up is that I’m currently working on a branch where I’m replacing Locust’s built in HttpBrowser with python requests lib (http://python-requests.org). I have now fully replaced the old client with requests, except for the catch_response feature, and not having to port that feature would save time and code lines 😃.
Does anyone use the catch_response feature extensively? Would anyone miss it 😃?
Issue Analytics
- State:
- Created 11 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Actually this got me thinking if maybe we could use the above solution to also solve the allow_http_error use cases.
If the API looked something like this:
But then again maybe it’s weird to wrap the real response object in some other CatchedResponse object, but I do like the fact that it would also solve the use cases where one would want to use the allow_http_error argument.
What do you think?
Fixed by #40