Skip to content

Commit

Permalink
Rename "missing catch_response=True"-methods. further clarify error m…
Browse files Browse the repository at this point in the history
…essage.
  • Loading branch information
Lars Holmberg committed Jun 17, 2024
1 parent 6804e32 commit 5e9a73f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions locust/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,11 @@ def init_poolmanager(self, *args, **kwargs):


# Monkey patch Response class to give some guidance
def _success(self, *_args, **_kwargs):
def _missing_catch_response_True(self, *_args, **_kwargs):
raise LocustError(
"If you want to change the state of the request, you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
"If you want to change the state of the request using .success() or .failure(), you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
)


def _failure(self, *_args, **_kwargs):
raise LocustError(
"If you want to change the state of the request, you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
)


Response.success = _success # type: ignore[attr-defined]
Response.failure = _failure # type: ignore[attr-defined]
Response.success = _missing_catch_response_True # type: ignore[attr-defined]
Response.failure = _missing_catch_response_True # type: ignore[attr-defined]

0 comments on commit 5e9a73f

Please sign in to comment.