繁体   English   中英

蝗虫,上传测试

[英]Locust, upload test

我是蝗虫新手,正在尝试进行第一次测试,上传带有标头和路径的简单文件,似乎无法设法使其正常工作

会很高兴为您提供任何帮助,谢谢!

我当前的测试是:

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

设法编写一个上传文件的测试:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM