如何在蝗虫中维持会话?

时间:2019-05-22 16:54:26

标签: django load-testing locust

如何在发布带有视图消耗请求的URL时传递请求对象?

locustfile.py

def login(self):
    self.__class__.user = self.__class__.user + 1
    data = self.get_user_data()
    csrf = self.get_csrf("/admin/login/")
    resp = self.client.post("/admin/login/", data, headers={"X-CSRFToken": csrf})
    if resp.status_code == 200:
        self.login_success = True
    else:
        self.login_success = False

views.py

def start_exam(request):

    try:
        user = request.user

0 个答案:

没有答案