From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sun, 5 Jan 2020 18:53:47 +0100
Subject: Fix nprocs

Forwarded: not-needed
---
 pysph/parallel/tests/test_parallel.py     | 12 ++++++++----
 pysph/parallel/tests/test_parallel_run.py |  7 +++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/pysph/parallel/tests/test_parallel.py b/pysph/parallel/tests/test_parallel.py
index 8397f0a..9896f5d 100644
--- a/pysph/parallel/tests/test_parallel.py
+++ b/pysph/parallel/tests/test_parallel.py
@@ -10,6 +10,9 @@ from pysph.tools import run_parallel_script
 
 path = run_parallel_script.get_directory(__file__)
 
+import os
+nprocs = int(os.environ.get('NPROCS', '1'))
+
 
 class ParticleArrayTestCase(unittest.TestCase):
     @classmethod
@@ -42,6 +45,7 @@ class ParticleArrayTestCase(unittest.TestCase):
         )
 
 
+@unittest.skipIf(nprocs !=4, 'only works with 4 processes')
 class ParticleArrayExchangeTestCase(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
@@ -69,7 +73,7 @@ class SummationDensityTestCase(unittest.TestCase):
     @mark.parallel
     def test_summation_density(self):
         run_parallel_script.run(
-            filename='summation_density.py', nprocs=4, path=path
+            filename='summation_density.py', nprocs=nprocs, path=path
         )
 
 
@@ -88,14 +92,14 @@ class MPIReduceArrayTestCase(unittest.TestCase):
     @mark.parallel
     def test_mpi_reduce_array(self):
         run_parallel_script.run(
-            filename='reduce_array.py', nprocs=4, path=path
+            filename='reduce_array.py', nprocs=nprocs, path=path
         )
 
     @mark.parallel
     def test_parallel_reduce(self):
         args = ['--directory=%s' % self.root]
         run_parallel_script.run(
-            filename='simple_reduction.py', args=args, nprocs=4, path=path
+            filename='simple_reduction.py', args=args, nprocs=nprocs, path=path
         )
 
 
@@ -108,7 +112,7 @@ class DumpLoadTestCase(unittest.TestCase):
     @mark.parallel
     def test_dump_and_load_work_in_parallel(self):
         run_parallel_script.run(
-            filename='check_dump_load.py', nprocs=4, path=path
+            filename='check_dump_load.py', nprocs=nprocs, path=path
         )
 
 
diff --git a/pysph/parallel/tests/test_parallel_run.py b/pysph/parallel/tests/test_parallel_run.py
index a39bd58..efbb7e9 100644
--- a/pysph/parallel/tests/test_parallel_run.py
+++ b/pysph/parallel/tests/test_parallel_run.py
@@ -11,6 +11,9 @@ from pytest import mark, importorskip
 from pysph.tools import run_parallel_script
 from pysph.parallel.tests.example_test_case import ExampleTestCase, get_example_script
 
+import os
+nprocs = int(os.environ.get('NPROCS', '1'))
+
 
 class ParallelTests(ExampleTestCase):
 
@@ -28,7 +31,7 @@ class ParallelTests(ExampleTestCase):
         extra_parallel_kwargs = dict(ghost_layers=1, lb_freq=5)
         self.run_example(
             get_example_script('sphysics/dambreak_sphysics.py'),
-            nprocs=4, atol=1e-12,
+            nprocs=nprocs, atol=1e-12,
             serial_kwargs=serial_kwargs,
             extra_parallel_kwargs=extra_parallel_kwargs
         )
@@ -50,7 +53,7 @@ class ParallelTests(ExampleTestCase):
         serial_kwargs = dict(max_steps=max_steps, pfreq=500, sort_gids=None)
         extra_parallel_kwargs = dict(ghost_layers=2, lb_freq=5)
         self.run_example(
-            'cavity.py', nprocs=4, atol=1e-14, serial_kwargs=serial_kwargs,
+            'cavity.py', nprocs=nprocs, atol=1e-14, serial_kwargs=serial_kwargs,
             extra_parallel_kwargs=extra_parallel_kwargs
         )
 
