如何使用py.test多核?

Eri*_*son 10 python pytest

查看py.test文档,似乎传递-n NUM将指定要使用的核心数.

我的经验如下:

usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: -n
Run Code Online (Sandbox Code Playgroud)

如果我尝试指定它pytest.ini(这是我的偏好),我得到相同的结果.

我添加addopts = -n4ini文件,这似乎是什么文件要求.

我正在使用py.test 2.8,我已经尝试了python 2和python 3.

Jam*_*ery 12

你需要安装 xdist

pip install pytest-xdist
Run Code Online (Sandbox Code Playgroud)