From 98804f957ac01a7a51953baf183e5d336a8ea1c0 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 19 Jul 2019 15:11:12 -0500 Subject: [PATCH] Parametrizing cell temperature test. --- tests/unit_tests/dagmc/conftest.py | 1 - tests/unit_tests/dagmc/test.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unit_tests/dagmc/conftest.py b/tests/unit_tests/dagmc/conftest.py index 6215322314..9f012b5faa 100644 --- a/tests/unit_tests/dagmc/conftest.py +++ b/tests/unit_tests/dagmc/conftest.py @@ -3,7 +3,6 @@ import pytest @pytest.fixture(scope='module', autouse=True) def setup_dagmc_unit_test(request): - # Change to test directory olddir = request.fspath.dirpath().chdir() try: diff --git a/tests/unit_tests/dagmc/test.py b/tests/unit_tests/dagmc/test.py index 2302ab7e45..7698119fc1 100644 --- a/tests/unit_tests/dagmc/test.py +++ b/tests/unit_tests/dagmc/test.py @@ -13,7 +13,8 @@ pytestmark = pytest.mark.skipif( not openmc.capi._dagmc_enabled(), reason="DAGMC CAD geometry is not enabled.") -def test_dagmc_temperatures(): +@pytest.fixture(scope="module", autouse=True) +def dagmc_model(): model = openmc.model.Model() # settings @@ -54,16 +55,9 @@ def test_dagmc_temperatures(): model.export_to_xml() - # check cell temps as well here openmc.capi.init() - expected_temps = { 1 : 320.0, # assigned by material - 2 : 300.0, # assigned in dagmc file - 3 : 293.6 } # assigned by default - - for cell_id, temp in expected_temps.items(): - capi_cell = openmc.capi.cells[cell_id] - assert np.isclose(capi_cell.get_temperature(), temp) + yield openmc.capi.finalize() @@ -73,3 +67,10 @@ def test_dagmc_temperatures(): for f in input_files: if os.path.exists(f): os.remove(f) + +@pytest.mark.parametrize("cell_id,exp_temp", ((1, 320.0), # assigned by material + (2, 300.0), # assigned in dagmc file + (3, 293.6))) # assigned by default +def test_dagmc_temperatures(cell_id, exp_temp): + cell = openmc.capi.cells[cell_id] + assert np.isclose(cell.get_temperature(), exp_temp)