2025-08-29 15:06:33 +03:00
|
|
|
import os
|
2018-02-09 16:17:12 -06:00
|
|
|
import pytest
|
2024-10-10 12:17:40 -05:00
|
|
|
import openmc
|
2018-02-09 16:17:12 -06:00
|
|
|
|
2018-01-29 13:46:40 -06:00
|
|
|
from tests.regression_tests import config as regression_config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
|
parser.addoption('--exe')
|
|
|
|
|
parser.addoption('--mpi', action='store_true')
|
|
|
|
|
parser.addoption('--mpiexec')
|
|
|
|
|
parser.addoption('--mpi-np')
|
|
|
|
|
parser.addoption('--update', action='store_true')
|
|
|
|
|
parser.addoption('--build-inputs', action='store_true')
|
2020-01-23 23:12:18 +00:00
|
|
|
parser.addoption('--event', action='store_true')
|
2018-01-29 13:46:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_configure(config):
|
2020-01-23 23:12:18 +00:00
|
|
|
opts = ['exe', 'mpi', 'mpiexec', 'mpi_np', 'update', 'build_inputs', 'event']
|
2018-01-29 13:46:40 -06:00
|
|
|
for opt in opts:
|
|
|
|
|
if config.getoption(opt) is not None:
|
|
|
|
|
regression_config[opt] = config.getoption(opt)
|
2018-02-09 16:17:12 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def run_in_tmpdir(tmpdir):
|
|
|
|
|
orig = tmpdir.chdir()
|
|
|
|
|
try:
|
|
|
|
|
yield
|
|
|
|
|
finally:
|
|
|
|
|
orig.chdir()
|
2025-11-13 17:14:39 -06:00
|
|
|
|
2025-08-29 15:06:33 +03:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
|
def endf_data():
|
2025-11-13 17:14:39 -06:00
|
|
|
return os.environ['OPENMC_ENDF_DATA']
|
2024-10-10 12:17:40 -05:00
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session', autouse=True)
|
|
|
|
|
def resolve_paths():
|
|
|
|
|
with openmc.config.patch('resolve_paths', False):
|
|
|
|
|
yield
|
2025-11-13 17:14:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session', autouse=True)
|
|
|
|
|
def disable_depletion_multiprocessing_under_mpi():
|
|
|
|
|
"""Fork-based depletion multiprocessing may deadlock if MPI is active."""
|
|
|
|
|
if not regression_config['mpi']:
|
|
|
|
|
yield
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
from openmc.deplete import pool
|
|
|
|
|
|
|
|
|
|
original_setting = pool.USE_MULTIPROCESSING
|
|
|
|
|
pool.USE_MULTIPROCESSING = False
|
|
|
|
|
try:
|
|
|
|
|
yield
|
|
|
|
|
finally:
|
|
|
|
|
pool.USE_MULTIPROCESSING = original_setting
|