【Python_pytest】pytest-parallel 多线程

 安装

pip install pytest-parallel

 

常用参数配置:

  • --workers=n:多进程运行需要加此参数, n是进程数。默认为1
  • --tests-per-worker=n:多线程需要添加此参数,n是线程数
# 3个进程运行
pytest test.py --workers 3
# 4个线程运行
pytest test.py --tests-per-worker 4
# 2个进程并行,且每个进程最多4个线程运行,即总共最多8个线程运行。
pytest test.py --workers 2 --tests-per-worker 4

 

<Tips:  多进程并发在linux或者mac上做,在Windows上不起作用(Workers=1)

    多线程linux/mac/windows平台都支持,进程数为workers的值。>

posted @ 2022-12-05 16:56  Phoenixy  阅读(422)  评论(0)    收藏  举报