Consistent use of cross sections / chain file in Operator class

This commit is contained in:
Paul Romano 2022-01-11 17:50:50 -06:00
parent 34ec14c5ee
commit badaaacca4
4 changed files with 60 additions and 78 deletions

View file

@ -10,7 +10,7 @@ from pathlib import Path
import pytest
from openmc.deplete.abc import TransportOperator
from openmc.deplete.chain import Chain
from openmc.deplete.chain import Chain, _find_chain_file
BARE_XS_FILE = "bare_cross_sections.xml"
CHAIN_PATH = Path(__file__).parents[1] / "chain_simple.xml"
@ -31,7 +31,7 @@ def bare_xs(run_in_tmpdir):
with open(BARE_XS_FILE, "w") as out:
out.write(bare_xs_contents)
yield
yield BARE_XS_FILE
class BareDepleteOperator(TransportOperator):
@ -54,14 +54,10 @@ class BareDepleteOperator(TransportOperator):
pass
@mock.patch.dict(environ, {"OPENMC_CROSS_SECTIONS": BARE_XS_FILE})
def test_operator_init(bare_xs):
"""The test will set and unset environment variable OPENMC_CROSS_SECTIONS
to point towards a temporary dummy file. This file will be removed
at the end of the test, and only contains a
depletion_chain node."""
# force operator to read from OPENMC_CROSS_SECTIONS
bare_op = BareDepleteOperator(chain_file=None)
"""The test uses a temporary dummy chain. This file will be removed
at the end of the test, and only contains a depletion_chain node."""
bare_op = BareDepleteOperator(_find_chain_file(bare_xs))
act_chain = bare_op.chain
ref_chain = Chain.from_xml(CHAIN_PATH)
assert len(act_chain) == len(ref_chain)