From a69e10485bc10a9f845550d73340338571489cd5 Mon Sep 17 00:00:00 2001 From: Svenn Tveit Date: Wed, 27 Aug 2025 12:50:30 +0200 Subject: [PATCH] Clarify ordering and clean up doc in rest of the tests --- python/test/test_primary_variables.py | 16 ++++++++++------ python/test/test_schedule.py | 3 --- python/test/test_throw.py | 3 --- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/python/test/test_primary_variables.py b/python/test/test_primary_variables.py index 143c494b88..b5c3f95f58 100644 --- a/python/test/test_primary_variables.py +++ b/python/test/test_primary_variables.py @@ -14,12 +14,15 @@ class TestBasic(unittest.TestCase): cls.data_dir_bo = test_dir.parent.joinpath("test_data/SPE1CASE1a") cls.data_dir_gw = test_dir.parent.joinpath("test_data/SPE1CASE2") + # IMPORTANT: Since all the python unittests run in the same process we must be + # careful to not call MPI_Init() more than once. + # Tests are run alphabetically, so we need to make sure that + # the the first test calls MPI_Init(), therefore the name of the tests + # have a numeric label like "01" in test_01_bo to ensure that they + # are run in a given order. - def test_all(self): - self._bo() - self._gw() - - def _bo(self): + # IMPORTANT:This test must be run first since it calls MPI_Init() + def test_01_blackoil(self): with pushd(self.data_dir_bo): sim = BlackOilSimulator("SPE1CASE1.DATA") sim.setup_mpi(True, False) @@ -48,7 +51,8 @@ class TestBasic(unittest.TestCase): variable='brine') self.assertEqual(brine_meaning[0], brine_meaning_map["Disabled"]) - def _gw(self): + # IMPORTANT: This test must be run last since it calls MPI_Finalize() + def test_99_gaswater(self): with pushd(self.data_dir_gw): sim = GasWaterSimulator("SPE1CASE2_GASWATER.DATA") sim.setup_mpi(False, True) diff --git a/python/test/test_schedule.py b/python/test/test_schedule.py index 584615b252..f811b1ff1d 100755 --- a/python/test/test_schedule.py +++ b/python/test/test_schedule.py @@ -13,9 +13,6 @@ from .pytest_common import pushd class TestBasic(unittest.TestCase): @classmethod def setUpClass(cls): - # NOTE: See comment in test_basic.py for the reason why we are - # only using a single test_all() function instead of splitting - # it up in multiple test functions test_dir = Path(os.path.dirname(__file__)) cls.data_dir = test_dir.parent.joinpath("test_data/SPE1CASE1b") diff --git a/python/test/test_throw.py b/python/test/test_throw.py index 6d2fa65556..73513d10cc 100644 --- a/python/test/test_throw.py +++ b/python/test/test_throw.py @@ -7,9 +7,6 @@ from .pytest_common import pushd class TestBasic(unittest.TestCase): @classmethod def setUpClass(cls): - # NOTE: See comment in test_basic.py for the reason why we are - # only using a single test_all() function instead of splitting - # it up in multiple test functions test_dir = Path(os.path.dirname(__file__)) cls.data_dir = test_dir.parent.joinpath("test_data/SPE1CASE1a")