Skip to main content

Package that supports mpi tests in pytest

Project description

Welcome to the pytest-easyMPI package!

This package aims at making MPI code testing as similar to testing regular serial code as possible. In doing so hopefully the users of this plugin can focus more on writing tests of their MPI code and spend less time figuring out how to integrate MPI tests into their other test cases.

Short example

The following shows an example of how to combine a serial and a parallel test in a single test file. The parallel test is run using 4 MPI ranks:

from pytest_easyMPI import mpi_parallel

def test_serial():
    assert True

def test_parallel():
    # Import MPI only inside the test that needs it
    # (to avoid spawning too many MPI communicators)
    from mpi4py import MPI

    data = MPI.COMM_WORLD.gather(MPI.COMM_WORLD.Get_rank())
    if MPI.COMM_WORLD.Get_rank() == 0:
        assert sum(range(MPI.COMM_WORLD.Get_size())) == sum(data)

The test can then be run by calling:


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-easyMPI-0.0.1.tar.gz (9.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page