解决Locust1.2.2脚本报错AttributeError: ‘UserBehavior‘ object has no attribute ‘locust‘的问题
问题:
locust进行接口性能测试,使用之前的locust脚本模板报错:AttributeError: 'UserBehavior' object has no attribute 'locust'
原因分析:
打开官方文档查看:https://docs.locust.io/en/latest/changelog.html#locust-class-renamed-to-user
发现是自己忽略了1.0到1.0.1中“The locust
attribute on TaskSet
instances has been renamed to user
.”TaskSet实例上的locust属性被重命名为user。
解决方法:
将脚本中TaskSet实例上的locust属性名全部替换为user。