Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use multiple cores with py.test?

Tags:

python

pytest

Looking at the py.test documentation it would seem that passing -n NUM would specify the number of cores to be used.

My experience is the following:

usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: -n

If I try to specify it in pytest.ini (which is my preference) I get the same result.

I'm adding addopts = -n4 to the ini file, which seems to be what the docs require.

I'm using py.test 2.8, and I've tried both python 2 and python 3.

like image 750
Eric Wilson Avatar asked Oct 08 '15 15:10

Eric Wilson


1 Answers

You need to install xdist

pip install pytest-xdist
like image 52
James Jeffery Avatar answered Oct 04 '22 14:10

James Jeffery