Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PyTest: Run tests in parallel with xdist

  • xdist
$ pip install pytest-xdist
$ pytest -n NUM
import time

def test_dog():
    time.sleep(2)

def test_cat():
    time.sleep(2)

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