diff --git a/tests/chain_test.xml b/tests/chain_test.xml deleted file mode 100644 index c8c75ad7b..000000000 --- a/tests/chain_test.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - 0.0253 - - A B - 0.0292737 0.002566345 - - - - diff --git a/tests/unit_tests/test_deplete_chain.py b/tests/unit_tests/test_deplete_chain.py index 8fc01b427..f7e7899a3 100644 --- a/tests/unit_tests/test_deplete_chain.py +++ b/tests/unit_tests/test_deplete_chain.py @@ -6,9 +6,44 @@ from pathlib import Path import numpy as np from openmc.deplete import comm, Chain, reaction_rates, nuclide +import pytest + +from tests import cdtemp -_test_filename = str(Path(__file__).parents[1] / 'chain_test.xml') +_TEST_CHAIN = """\ + + + + + + + + + + + + + + + + 0.0253 + + A B + 0.0292737 0.002566345 + + + + +""" + + +@pytest.fixture(scope='module') +def simple_chain(): + with cdtemp(): + with open('chain_test.xml', 'w') as fh: + fh.write(_TEST_CHAIN) + yield Chain.from_xml('chain_test.xml') def test_init(): @@ -33,13 +68,13 @@ def test_from_endf(): pass -def test_from_xml(): +def test_from_xml(simple_chain): """Read chain_test.xml and ensure all values are correct.""" # Unfortunately, this routine touches a lot of the code, but most of # the components external to depletion_chain.py are simple storage # types. - chain = Chain.from_xml(_test_filename) + chain = simple_chain # Basic checks assert len(chain) == 3 @@ -125,16 +160,15 @@ def test_export_to_xml(run_in_tmpdir): chain.nuclides = [A, B, C] chain.export_to_xml(filename) - original = open(_test_filename, 'r').read() chain_xml = open(filename, 'r').read() - assert original == chain_xml + assert _TEST_CHAIN == chain_xml -def test_form_matrix(): +def test_form_matrix(simple_chain): """ Using chain_test, and a dummy reaction rate, compute the matrix. """ # Relies on test_from_xml passing. - chain = Chain.from_xml(_test_filename) + chain = simple_chain mats = ["10000", "10001"] nuclides = ["A", "B", "C"]