-
Notifications
You must be signed in to change notification settings - Fork 3k
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
resp.failure() shouldnt immediately log a failed request, just mark it a such #1335
Comments
Hmm, The following code works perfectly fine for me (with either HttpLocust or FastHttpLocust): from locust import HttpLocust, task, constant
from locust.contrib.fasthttp import FastHttpLocust
class TestUser(HttpLocust):
host = "http://127.0.0.1:8089"
wait_time = constant(1)
@task
def test_task(self):
with self.client.post("/non-existing", catch_response=True) as resp:
resp.failure("Noooo, fail!")
print("request failed")
return
print("end of task (should never run)") Command line output:
|
Oh, right, I'm totally misremembering. It is possible to do the first thing I posted, just not the second one. For example, doing this:
... will log two requests, one failure, and one success. |
... and that is bad because it makes it hard to build a more advanced client/user (for example, one that does custom error checking, but allows the error to be overridden/removed in cases where an error is expected) |
Ah, I see what you mean! Definitely agree. Only the last call to either I have a failing test for it now. I'll set up a PR.
I don't think it they should be properties. I think it's useful to be able to pass a message to the |
PR submitted! |
Because resp.failure() immediately logs a failure
trows an exception, it is kind of hard to work with.edit: I was confused, this first thing is entirely possible today
For instance, if you want to tag the request as a failure and then break out of the task entirely, you cant really do that in a straight forward way.I would like to be able to do this:or even this (particularly useful when you have wrapped the request method and it does some kind of error checking internally, which you may want to override sometimes):
Probably we should also change it from being a method call to being a property.
Because this is potentially a breaking change for some testplans I would like to do it for 1.0
The text was updated successfully, but these errors were encountered: