属性错误:尝试运行蝗虫时没有属性'MyApiTask' 'task_set'的类型对象



我的代码是这样的

class MyApiTask(TaskSet):
def __init__(self):
super().__init__(self)
@task(1)
def get_response(self):
response  = self.client.get("/")
print(response.json())
assert_that(200).is_equal_to(response.status_code)
class MyApiUser(HttpLocust):
task_set = MyApiTask
wait_time = between(1,2)

当我运行它时,我得到:

AttributeError:尝试运行蝗虫时,类型对象"MyApiTask"没有属性"task_set">

请帮忙!

看起来您还没有更新到1.x语法?

MyApiUser(HttpLocust):

只要看看当前的一个例子,你就应该没事了。

https://docs.locust.io/en/stable/quickstart.html

最新更新