一个用于并行和并发测试的pytest插件
项目描述
pytest-parallel
一个用于并行和并发测试的pytest插件
是什么?
此插件通过多进程(并行)和多线程(并发)使快速运行测试成为可能。
为什么?
pytest-xdist
适用于运行以下测试
- 不是线程安全的
- 在多线程下表现不佳
- 需要状态隔离
pytest-parallel
适用于某些用例(如Selenium测试),这些用例
- 可以线程安全
- 可以使用非阻塞IO进行http请求以提高性能
- 在Python环境中管理少量或无状态
简单来说,pytest-xdist
执行并行,而 pytest-parallel
执行并行和并发。
要求
- Python3版本 [3.6+]
- Unix或Mac用于
--workers
- Unix、Mac或Windows用于
--tests-per-worker
安装
pip安装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.
许可协议
MIT
项目详情
关闭
pytest-parallel-0.1.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9aac3fc199a168c0a8559b60249d9eb254de7af58c12cee0310b54d4affdbfab |
|
MD5 | 8779d17a8da9cdb45145a8ca27a7db5d |
|
BLAKE2b-256 | ed0ea74218b99ae0fbab09fabc0ad01e763b32abbeaa96a27188782e9d6289db |
关闭
pytest_parallel-0.1.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9e3703015b0eda52be9e07d2ba3498f09340a56d5c79a39b50f22fc5c38212fe |
|
MD5 | d1b502946186470889fa1c6551057ff8 |
|
BLAKE2b-256 | 14d2a2cf7da29753a222d19a682d50fb3cb605544cec66770553611119c857d2 |