蝗虫,上传测试

时间:2016-07-31 07:22:05

标签: python upload locust

我是蝗虫的新手并试图进行我的第一次测试,使用标题和路径上传简单文件,似乎无法使其工作

很高兴得到任何帮助,谢谢!

我目前的测试是:

class UserBehavior(TaskSet):
        @task
        def post_img(self):
                self.client.headers['1'] = "1"
                self.client.headers['1'] = "1"
                test_file = 'PATH/TO.FILE'
                self.client.post("address", files={'file': open(test_file, 'rb')})


class WebsiteUser(HttpLocust):
        host = 'IP'
        task_set = UserBehavior
        min_wait = 100
        max_wait = 300

1 个答案:

答案 0 :(得分:4)

管理编写上传文件的测试:

class HttpSession(TaskSet):
        @task
        def post_img(self):
        headers = {'1': '1', '2': '2'}
                test_file = '/pathTo/file.jpg'
                self.client.request('POST', 'url', files={'file': open(test_file, 'rb')}, headers=headers)


class WebsiteUser(HttpLocust):
        host = 'http://IP'
        task_set = HttpSession
        min_wait = 100
        max_wait = 300
相关问题