美文网首页Python WebPython
Python - 常用Packages

Python - 常用Packages

作者: 红薯爱帅 | 来源:发表于2019-06-08 18:08 被阅读0次

1. PyInstaller - 打包Python程序

http://www.pyinstaller.org/

$ pip install pyinstaller
$ pyinstaller yourprogram.py
image.png

2. Locust - 测试工具,可完成压力测试、功能测试等

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

  • test script
from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    def on_start(self):
        """ on_start is called when a Locust start before any task is scheduled """
        self.login()

    def on_stop(self):
        """ on_stop is called when the TaskSet is stopping """
        self.logout()

    def login(self):
        self.client.post("/login", {"username":"ellen_key", "password":"education"})

    def logout(self):
        self.client.post("/logout", {"username":"ellen_key", "password":"education"})

    @task(2)
    def index(self):
        self.client.get("/")

    @task(1)
    def profile(self):
        self.client.get("/profile")

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000
  • run for test
$ locust -f locust_files/my_locust_file.py --host=http://example.com
image.png

`

相关文章

网友评论

    本文标题:Python - 常用Packages

    本文链接:https://www.haomeiwen.com/subject/sganzqtx.html