Registry / testing / pytest-mpi

pytest-mpi

JSON →
library0.6pypypi✓ verified 85d ago

pytest-mpi is a pytest plugin that provides fixtures and markers for tests requiring MPI (Message Passing Interface) support, enabling parallel test execution across multiple processes. Version 0.6 is the latest, with infrequent releases.

pip install pytest-mpi
INSTALL
IMPORT
SIG · PYTEST-MPI
P
pytest-mpi
testingpythonv0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MPIPlugin
from pytest_mpi import MPIPlugin
from pytest_mpi import mpi_skip
mpi_tmp_path
from pytest_mpi import mpi_tmp_path
mpi_tmpdir
from pytest_mpi import mpi_tmpdir

Simple test using mpi fixture and mpi_skip decorator.

import pytest from pytest_mpi import mpi_skip @mpi_skip(reason="Requires MPI") def test_mpi_example(mpi): rank = mpi.Get_rank() size = mpi.Get_size() assert size > 0 print(f"Hello from rank {rank} out of {size}") # Run with: mpirun -n 4 pytest -v test_mpi.py
Debug
Known issues
gotchaThe @mpi_skip decorator must be placed before @pytest.mark.parametrize to avoid skipping incorrectly.
fix
Always put @mpi_skip as the outermost decorator (right above def).
affects: all
deprecatedThe 'mpi' fixture may return a different MPI communicator object in future versions; currently it returns the MPI.COMM_WORLD.
fix
Use mpi fixture directly; check version changelogs for changes.
affects: >=0.5
breakingpytest-mpi 0.5 removed support for MPI_Gather and MPI_Allgather fixtures; use mpi_skip with custom MPI calls instead.
fix
Replace @mpi_gather and @mpi_allgather with @mpi_skip and manual MPI calls.
affects: 0.5+
Upgrade
Version history
0.6latest on PyPI · released Jan 8, 2022
Audit
Dependencies
mpi4pyrequiredRequired for MPI communication in tests.
pytestrequiredpytest-mpi is a pytest plugin.
Agent activity
4 hits · last 30 days
node
4
Resources
pytest-mpi — pip install pytest-mpi · libregistry