1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
from pytest_mpi._helpers import _fix_plural
MPI_FILE_NAME_TEST_CODE = """
import pytest
def test_file_name(mpi_file_name):
from mpi4py import MPI
comm = MPI.COMM_WORLD
name = str(mpi_file_name)
names = comm.gather(name, root=0)
if comm.rank == 0:
for n in names:
assert n == name
else:
assert names is None
"""
MPI_TMPDIR_TEST_CODE = """
import pytest
def test_file_name(mpi_tmpdir):
from mpi4py import MPI
comm = MPI.COMM_WORLD
name = str(mpi_tmpdir)
names = comm.gather(name, root=0)
if comm.rank == 0:
for n in names:
assert n == name
else:
assert names is None
"""
MPI_TMP_PATH_TEST_CODE = """
import pytest
def test_file_name(mpi_tmp_path):
from mpi4py import MPI
comm = MPI.COMM_WORLD
name = str(mpi_tmp_path)
names = comm.gather(name, root=0)
if comm.rank == 0:
for n in names:
assert n == name
else:
assert names is None
"""
def test_mpi_file_name(mpi_testdir, has_mpi4py):
mpi_testdir.makepyfile(MPI_FILE_NAME_TEST_CODE)
result = mpi_testdir.runpytest("--with-mpi", timeout=None)
if has_mpi4py:
result.assert_outcomes(passed=1)
else:
result.assert_outcomes(**_fix_plural(errors=1))
def test_mpi_tmpdir(mpi_testdir, has_mpi4py):
mpi_testdir.makepyfile(MPI_TMPDIR_TEST_CODE)
result = mpi_testdir.runpytest("--with-mpi", timeout=None)
if has_mpi4py:
result.assert_outcomes(passed=1)
else:
result.assert_outcomes(**_fix_plural(errors=1))
def test_mpi_tmp_path(mpi_testdir, has_mpi4py):
mpi_testdir.makepyfile(MPI_TMP_PATH_TEST_CODE)
result = mpi_testdir.runpytest("--with-mpi", timeout=None)
if has_mpi4py:
result.assert_outcomes(passed=1)
else:
result.assert_outcomes(**_fix_plural(errors=1))
|