A pytest plugin that lets test functions be coroutines, so you can await asyncio code directly inside tests.
pytest-dev/pytest-xdist
A pytest plugin that runs tests in parallel across multiple CPUs and adds a loop-on-failures mode.
- Stars
- 1,931
- Forks
- 298
- Open issues
- 317
- Last commit
- 4 days ago
What is it?
pytest-xdist extends the pytest test runner with new execution modes. Its main use is distributing tests across multiple CPUs to shorten test runs: running `pytest -n auto` starts one worker process per available CPU and spreads the tests across them.
Besides parallel execution, the plugin provides a loop-on-failures testing mode for repeatedly running failing tests while you fix them. It is installed as a pytest plugin and works with existing pytest test suites without changing how tests are written.
Key features
- 01Runs tests in parallel across multiple CPUs with `pytest -n`.
- 02Automatically sets the worker count to the number of available CPUs with `-n auto`.
- 03Provides a loop-on-failures mode for repeatedly re-running failing tests.
- 04Works as a plugin with existing pytest test suites.
Use cases
- Speeding up a large pytest suite that takes too long to run serially.
- Repeatedly re-running flaky or failing tests while debugging.
- Running a test suite on a multi-core development machine or CI runner.
Quick start
- 1
Run your test suite in parallel across CPUs
pytest -n auto
In collections
Topics
FAQ
- What is pytest-xdist?
- A pytest plugin that runs tests in parallel across multiple CPUs and adds a loop-on-failures mode. pytest-xdist extends the pytest test runner with new execution modes. Its main use is distributing tests across multiple CPUs to shorten test runs: running `pytest -n auto` starts one worker process per available CPU and spreads the tests across them.
- Is pytest-xdist free to use? What license does it have?
- pytest-xdist is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pytest-xdist still maintained?
- Actively maintained. The last commit to pytest-xdist was on Nov 2, 2026.
- What can I use pytest-xdist for?
- Speeding up a large pytest suite that takes too long to run serially. Repeatedly re-running flaky or failing tests while debugging. Running a test suite on a multi-core development machine or CI runner.
- How do I install pytest-xdist?
- Run your test suite in parallel across CPUs: pytest -n auto
- Where can I get pytest-xdist?
- The source code and installation instructions are on GitHub: https://github.com/pytest-dev/pytest-xdist
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A BDD framework that runs Gherkin feature files as pytest tests, with no separate test runner needed.
A Python package that finds and runs the example code in docstrings, rewriting the builtin doctest module with an AST-based parser.
A Python library that records HTTP interactions made during tests and replays them later, so tests run offline and deterministically.
A pytest plugin that re-runs only the tests affected by your recent code changes, with optional continuous watch mode.
A pytest plugin that randomly shuffles test order and resets random seeds so failures caused by ordering or random data can be reproduced.