Skip to content

Commit e57544b

Browse files
committed
test: skip MPI-launcher run test when libmpi is absent
test_mpirun_launch_imports_mpi forces an mpirun-style env, which makes shapepipe.run import mpi4py.MPI. On the bare fast-tests runner mpi4py the package imports but the MPI runtime library (libmpi.so, provided by the dev image) is missing, so mpi4py.MPI raises RuntimeError — not the ImportError that pytest.importorskip('mpi4py') guards against. Guard on importing mpi4py.MPI directly and skip on any failure, matching the workflow's self-skip pattern for system-dependent tests. The dev-image CI still exercises the real MPI path. (run.py's launcher gate is unchanged and correct; test_bare_launch_skips_mpi already passes everywhere.)
1 parent b6ec343 commit e57544b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/module/test_run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,12 @@ def test_bare_launch_skips_mpi():
5050

5151
def test_mpirun_launch_imports_mpi():
5252
"""An mpirun-style env (OMPI_COMM_WORLD_SIZE) must import MPI."""
53-
pytest.importorskip("mpi4py")
53+
# mpi4py the package may import while the MPI runtime library
54+
# (libmpi.so) is absent — that is the case on a bare runner, where the
55+
# dev-image-provided MPI is missing. Importing mpi4py.MPI actually loads
56+
# libmpi, so skip on its failure (not just a plain ImportError).
57+
try:
58+
from mpi4py import MPI # noqa: F401
59+
except Exception:
60+
pytest.skip("MPI runtime not available (provided by the dev image)")
5461
assert _import_mpi_flag({"OMPI_COMM_WORLD_SIZE": "1"}) == "True"

0 commit comments

Comments
 (0)