@@ -63,11 +63,13 @@ MPI Tests always stop at the first error; because MPI is not fault tolerant [1].
63
63
python run-tests.py --mpirun="mpirun -np 4"
64
64
```
65
65
66
- ## Defining MPI UnitTests: MPITest decorator
66
+ ## Defining MPI UnitTests:
67
67
68
68
This feature may belong to a different package; it resides here for now before we can
69
69
find a reasonable refactoring of the package.
70
70
71
+ ### MPITest decorator
72
+
71
73
`MPITest` decorator allows testing with different MPI communicator sizes.
72
74
73
75
Example:
@@ -79,6 +81,40 @@ Example:
79
81
result = myfunction(comm)
80
82
assert result # or ....
81
83
```
84
+
85
+ ### MPITestFixture
86
+
87
+ You can combine `MPITestFixture` with other pytest fixtures or decorators, what you can't with the `MPITest` decorator.
88
+
89
+ Example: Parameter variation with `pytest.mark.parametrize`
90
+
91
+ ```python
92
+ from runtests.mpi import MPITestFixture
93
+ import pytest
94
+
95
+ comm = MPITestFixture([1,2,3, 4,10], scope='function')
96
+
97
+ @pytest.mark.parametrize("msg",["hello","world"])
98
+ def test_y(msg, comm):
99
+ print(msg, comm.Get_rank())
100
+ ```
101
+
102
+ Example: Parameter variation with ` pytest.fixture `
103
+ ``` python
104
+ from runtests.mpi import MPITestFixture
105
+ import pytest
106
+
107
+ comm = MPITestFixture([1 ,2 ,3 ,4 ], scope = ' function' )
108
+
109
+ @pytest.fixture (params = [" hello" ," world" ])
110
+ def x (request ):
111
+ return request.param
112
+
113
+ def test_x (x , comm ):
114
+ print (x, comm.Get_rank())
115
+ ```
116
+
117
+
82
118
## Tricks
83
119
84
120
0 commit comments