PyTest: Run tests in parallel with xdist



$ pip install pytest-xdist
$ pytest -n NUM


examples/pytest/xdist/test_animals.py
import time

def test_dog():
    time.sleep(2)

def test_cat():
    time.sleep(2)

examples/pytest/xdist/test_colors.py
import time

def test_blue():
    time.sleep(2)

def test_green():
    time.sleep(2)

pytest          8.04 sec
pytest -n 2     4.64 sec
pytest -n 4     3.07 sec