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
Hi,
I am following the example in your documentation to change the response status. My code looks like something this:
with self.client.post(url, data, ...) as response:
if response.status_code == 200 or response.status_code == 401:
response.success()
However, I keep getting the following python errors while running it. It seems the __exit__ method was not found so the "with" syntax wouldn't work.
Not sure if it's a bug or anything else I have to do to make it work. Your help will be really appreciated.
Thanks,
--Jiunjiun
[2014-06-18 10:07:46,757] jma/ERROR/stderr: Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/locust/core.py", line 267, in run
self.execute_next_task()
File "/Library/Python/2.7/site-packages/locust/core.py", line 293, in execute_next_task
self.execute_task(task["callable"], _task["args"], *_task["kwargs"])
File "/Library/Python/2.7/site-packages/locust/core.py", line 305, in execute_task
task(self, _args, *_kwargs)
File "/Users/jma/PycharmProjects/locust/rtc-register.py", line 52, in generate_account_token_form_post
self.validate_credential(username, password)
File "/Users/jma/PycharmProjects/locust/rtc-register.py", line 69, in validate_credential
with self.client.post(url, data, headers = {'content-type': 'application/json'}) as response:
AttributeError: exit
The text was updated successfully, but these errors were encountered:
In order to make Locust's HTTP client return a context manager (that can be used with the with statement), you must add catch_response=True to the arguments. Like this:
Hi,
I am following the example in your documentation to change the response status. My code looks like something this:
with self.client.post(url, data, ...) as response:
if response.status_code == 200 or response.status_code == 401:
response.success()
Thanks,
--Jiunjiun
[2014-06-18 10:07:46,757] jma/ERROR/stderr: Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/locust/core.py", line 267, in run
self.execute_next_task()
File "/Library/Python/2.7/site-packages/locust/core.py", line 293, in execute_next_task
self.execute_task(task["callable"], _task["args"], *_task["kwargs"])
File "/Library/Python/2.7/site-packages/locust/core.py", line 305, in execute_task
task(self, _args, *_kwargs)
File "/Users/jma/PycharmProjects/locust/rtc-register.py", line 52, in generate_account_token_form_post
self.validate_credential(username, password)
File "/Users/jma/PycharmProjects/locust/rtc-register.py", line 69, in validate_credential
with self.client.post(url, data, headers = {'content-type': 'application/json'}) as response:
AttributeError: exit
The text was updated successfully, but these errors were encountered: