{"id":27303,"library":"pytest-mpi","title":"pytest-mpi","description":"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.","status":"active","version":"0.6","language":"python","source_language":"en","source_url":"https://github.com/johannes-kuhn/pytest-mpi","tags":["pytest","plugin","mpi","parallel","testing"],"install":[{"cmd":"pip install pytest-mpi","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for MPI communication in tests.","package":"mpi4py","optional":false},{"reason":"pytest-mpi is a pytest plugin.","package":"pytest","optional":false}],"imports":[{"note":"Common mistake: using 'pytest.mpi' instead of 'pytest_mpi'.","wrong":"from pytest.mpi import mpi_skip","symbol":"mpi_skip","correct":"from pytest_mpi import mpi_skip"},{"note":"The fixture 'mpi' is provided by the plugin, not by pytest itself.","wrong":"from pytest import mpi","symbol":"mpi","correct":"from pytest_mpi import mpi"}],"quickstart":{"code":"import pytest\nfrom pytest_mpi import mpi_skip\n\n@mpi_skip(reason=\"Requires MPI\")\ndef test_mpi_example(mpi):\n    rank = mpi.Get_rank()\n    size = mpi.Get_size()\n    assert size > 0\n    print(f\"Hello from rank {rank} out of {size}\")\n\n# Run with: mpirun -n 4 pytest -v test_mpi.py","lang":"python","description":"Simple test using mpi fixture and mpi_skip decorator."},"warnings":[{"fix":"Always put @mpi_skip as the outermost decorator (right above def).","message":"The @mpi_skip decorator must be placed before @pytest.mark.parametrize to avoid skipping incorrectly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use mpi fixture directly; check version changelogs for changes.","message":"The 'mpi' fixture may return a different MPI communicator object in future versions; currently it returns the MPI.COMM_WORLD.","severity":"deprecated","affected_versions":">=0.5"},{"fix":"Replace @mpi_gather and @mpi_allgather with @mpi_skip and manual MPI calls.","message":"pytest-mpi 0.5 removed support for MPI_Gather and MPI_Allgather fixtures; use mpi_skip with custom MPI calls instead.","severity":"breaking","affected_versions":"0.5+"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install pytest-mpi' and ensure you import from 'pytest_mpi' (underscore, not dot).","cause":"The plugin is not installed or the import path is wrong.","error":"ModuleNotFoundError: No module named 'pytest_mpi'"},{"fix":"Install pytest-mpi: pip install pytest-mpi. Also check that you are running pytest with the plugin enabled; it should auto-register.","cause":"pytest-mpi is not installed or the plugin is not activated.","error":"pytest: error: unrecognized arguments: --mpi"},{"fix":"Install an MPI implementation (e.g., 'sudo apt install openmpi-bin' on Ubuntu) and ensure 'mpirun' is in PATH.","cause":"MPI runtime (e.g., OpenMPI, MPICH) is not installed or not configured correctly.","error":"ValueError: The MPI library failed to initialize"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}