Registry / testing / pytest-split

pytest-split

JSON →
library0.11.0pypypiunverified

Pytest plugin (version 0.11.0) which splits the test suite into equally sized sub-suites based on test execution time. This enables faster and more balanced parallelization of tests in CI/CD environments. It is actively maintained with a consistent release cadence, often including support for new Python and Pytest versions.

pip install pytest-split
INSTALL
IMPORT
SIG · PYTEST-SPLIT
P
pytest-split
testingpythonv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

First, run pytest with the `--store-durations` flag to collect and save the execution times of your tests into a `.test_durations` file. This file should be committed to your repository. Then, use the `--splits N --group X` flags to divide your test suite into `N` groups and execute only the tests belonging to group `X`. This is typically used in CI/CD pipelines to parallelize test execution across multiple jobs.

# 1. Store test durations from a complete test suite run pytest --store-durations # This creates a .test_durations file in the current directory. # It should be committed to your repository. # 2. Split and run a specific group of tests (e.g., group 1 of 3 total splits) pytest --splits 3 --group 1
pytest --version
Debug
Known issues
breakingSupport for older Python versions has been progressively removed. Version 0.11.0 dropped support for Python 3.8 and 3.9. Version 0.9.0 dropped support for Python 3.7. Ensure your environment uses Python 3.10 or newer (up to 3.14).
fix
Upgrade to a supported Python version (>=3.10) or pin pytest-split to an older version compatible with your Python environment.
affects: <0.11.0
breakingOlder versions of pytest-split (prior to 0.8.1) might use deprecated pytest APIs, potentially causing issues or warnings with newer pytest releases. Ensure you are on a recent version to maintain compatibility.
fix
Upgrade to pytest-split>=0.8.1 to ensure compatibility with updated pytest APIs.
affects: <0.8.1
gotchaWhen using test-order randomization plugins (e.g., `pytest-randomly`, `pytest-random-order`) with the default `duration_based_chunks` splitting algorithm, tests might be selected in multiple groups or not at all. This algorithm is incompatible with such plugins.
fix
If using randomization plugins, switch to the `least_duration` algorithm (`--splitting-algorithm least_duration`) or ensure a global random seed is computed and used for all groups via `--random-order-seed`.
affects: All versions
gotchaWhile `pytest-split` can handle new/removed tests by assuming average execution times, major changes to your test suite (many new/removed/renamed tests) can lead to unbalanced splits over time. The `.test_durations` file should be periodically updated.
fix
Regularly re-run `pytest --store-durations` after significant changes to your test suite to update the `.test_durations` file and ensure optimal, balanced test splitting.
affects: All versions
deprecatedThe format of the `.test_durations` file changed in version 0.4.0. While not explicitly stated as a breaking change for existing files, it might affect custom parsing logic if you relied on the older format.
fix
If you have custom tooling that processes the `.test_durations` file and are on an older version, be aware of potential format changes when upgrading. It's best to regenerate the file with `pytest --store-durations` after upgrading.
affects: <0.4.0
breakingThe test script attempts to execute shell commands directly as Python code, resulting in a `SyntaxError`. This prevents the actual execution of pytest and the library under test.
fix
Ensure that `pytest` is invoked as a shell command (e.g., directly in the shell or via a dedicated shell script) rather than being placed within a Python file that is then executed by the Python interpreter.
affects: All versions
gotchaAttempting to execute shell commands like `pytest --splits ...` directly as a Python script will result in a `SyntaxError`. Python cannot interpret shell commands as valid Python syntax.
fix
Ensure pytest commands are executed directly in the shell (e.g., via `subprocess.run()` in Python scripts, or as a direct command in a Dockerfile/shell entrypoint) and are not parsed by the Python interpreter as Python code.
affects: All versions
Errors
Common errors & fixes
ERROR: unknown option --split-tests
The `pytest-split` plugin is not installed or not loaded by pytest, so the `--split-tests` command-line option is unrecognized.
fix
Ensure `pytest-split` is installed in the active Python environment where pytest is being run: `pip install pytest-split`.
ValueError: Option --dist=loadgroup is not supported.
The `pytest-split` plugin is not compatible with `pytest-xdist`'s `--dist=loadgroup` option for parallel test execution.
fix
When using `pytest-xdist` with `pytest-split`, use `--dist=loadfile` or `--dist=each` instead of `--dist=loadgroup`, for example: `pytest --split-tests 2 --splits 1 --dist=loadfile`.
FileNotFoundError: No such file or directory: '.pytest_splits'
The plugin tried to read a splits file (e.g., the default `.pytest_splits` or one specified by `--splits-path`) that does not exist, often occurring when `--splits` is used before an initial `--split-tests` run or if the file was deleted.
fix
To generate a new splits file, run `pytest --split-tests <NUM_SPLITS>` without `--splits`; if you intend to use an existing file, ensure it's present and correctly located or specified via `--splits-path`.
PytestSplitError: Cannot combine --split-tests with --splits.
The `pytest-split` plugin was invoked with both `--split-tests` (to generate splits) and `--splits` (to use existing splits) simultaneously, which are mutually exclusive operations.
fix
Use either `--split-tests <NUM_SPLITS>` to generate new split definitions, or `--splits <INDEX>` to run a specific split using previously generated data, but not both in the same command.
PytestSplitError: Split index N out of range [0, M-1].
The `--splits N` option was used to request a split index `N` that is outside the valid 0-based range of splits (0 to M-1) created by a previous `--split-tests M` command.
fix
Ensure the value provided for `--splits` is a valid 0-based index (e.g., if `--split-tests 3` was used, valid indices are 0, 1, or 2).
Upgrade
Version history
0.11.0latest on PyPI · released Feb 3, 2026
Audit
Dependencies
pytestrequiredpytest-split is a plugin for the pytest testing framework and requires pytest to function. It explicitly requires pytest>=7.0.0.
Agent activity
26 hits · last 30 days
node
24
Resources
pytest-split — pip install pytest-split · libregistry