用于并行和并发测试的 pytest 插件
项目描述
pytest 并行
用于并行和并发测试的 pytest 插件
什么?
这个插件可以使用多处理(并行)和多线程(并发)快速运行测试。
为什么?
pytest-xdist非常适合运行以下测试:
- 不是线程安全的
- 多线程时性能不佳
- 需要状态隔离
pytest-parallel对于某些用例(如 Selenium 测试)更好:
- 可以是线程安全的
- 可以对 http 请求使用非阻塞 IO 来提高性能
- 在 Python 环境中管理很少或没有状态
简而言之,pytest-xdist并行pytest-parallel性是并行性和并发性。
要求
- Python3 版本 [3.6+]
- 适用于 Unix 或 Mac
--workers - 适用于 Unix、Mac 或 Windows
--tests-per-worker
安装
pip install pytest-parallel
选项
workers(可选)- 启动最大工作人员(又名进程)。可以是正整数,auto也可以是每个核心使用一个工作人员。默认为 1。tests-per-worker(可选) - 每个工作人员的最大并发测试数。可以是正整数,auto也可以在工作人员之间平均分配测试,最多 50 个并发测试。默认为 1。
例子
# runs 2 workers with 1 test per worker at a time
pytest --workers 2
# runs 4 workers (assuming a quad-core machine) with 1 test per worker
pytest --workers auto
# runs 1 worker with 4 tests at a time
pytest --tests-per-worker 4
# runs 1 worker with up to 50 tests at a time
pytest --tests-per-worker auto
# runs 2 workers with up to 50 tests per worker
pytest --workers 2 --tests-per-worker auto
注意
从 Python 3.8 开始,在 macOS 上强制分叉行为以牺牲安全为代价。
Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725.
执照
麻省理工学院
项目详情
关
pytest_parallel -0.1.1-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 9e3703015b0eda52be9e07d2ba3498f09340a56d5c79a39b50f22fc5c38212fe |
|
| MD5 | d1b502946186470889fa1c6551057ff8 |
|
| 布莱克2-256 | 14d2a2cf7da29753a222d19a682d50fb3cb605544cec66770553611119c857d2 |