You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use locust under python3.5.3 to learn to do some performance testing demo, some code as below.
class UserBehavior(TaskSet):
# Execute before any task
def on_start(self):
pass
@task(1)
def api_query(self):
with self.client.get("/api/nodes/show.json?name=python") as response:
if response.content == "":
response.failure("No data")
if json.loads(response.content.decode())["id"] != "90":
response.failure("Got wrong response, id=" + response.content.decode())
else:
response.success("Verify Ok!")
when i run locust, i get error message:
cent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 271, in run
self.execute_next_task()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 297, in execute_next_task
self.execute_task(task["callable"], *task["args"], **task["kwargs"])
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 309, in execute_task
task(self, *args, **kwargs)
File "/Users/xiongyang/Desktop/个人/learnning/python3/rfinex_locust.py", line 29, in login
response.failure("Got wrong response, id=" + response.content.decode())
AttributeError: 'Response' object has no attribute 'failure'
@mpaddle is correct. In order to be able to use the response object as a context manager (with the with statement), you have to set the catch_response keyword argument to True.
Description of issue / feature request
I use locust under python3.5.3 to learn to do some performance testing demo, some code as below.
class UserBehavior(TaskSet):
when i run locust, i get error message:
cent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 271, in run
self.execute_next_task()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 297, in execute_next_task
self.execute_task(task["callable"], *task["args"], **task["kwargs"])
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/locust/core.py", line 309, in execute_task
task(self, *args, **kwargs)
File "/Users/xiongyang/Desktop/个人/learnning/python3/rfinex_locust.py", line 29, in login
response.failure("Got wrong response, id=" + response.content.decode())
AttributeError: 'Response' object has no attribute 'failure'
Expected behavior
TBD
Actual behavior
TBD
Environment settings (for bug reports)
Steps to reproduce (for bug reports)
TBD - example code appreciated
The text was updated successfully, but these errors were encountered: