@@ -0,0 +1,2120 @@
+%22%22%22Basic unit tests for openmc.deplete.Operator instantiation%0A%0AModifies and resets environment variable OPENMC_CROSS_SECTIONS%0Ato a custom file with new depletion_chain node%0A%22%22%22%0A%0Afrom os import remove%0Afrom os import environ%0Afrom unittest import mock%0Afrom pathlib import Path%0Aimport pytest%0A%0Afrom openmc.deplete.abc import TransportOperator%0Afrom openmc.deplete.chain import Chain%0A%0ABARE_XS_FILE = %22bare_cross_sections.xml%22%0ACHAIN_PATH = Path().cwd() / %22tests%22 / %22chain_simple.xml%22%0A%0A%0A@pytest.fixture(scope=%22module%22)%0Adef bare_xs():%0A    %22%22%22Create a very basic cross_sections file, return simple Chain.%0A%0A    %22%22%22%0A%0A    bare_xs_contents = %22%22%22%3C?xml version=%221.0%22?%3E%0A%3Ccross_sections%3E%0A  %3Cdepletion_chain path=%22%7B%7D%22 /%3E%0A%3C/cross_sections%3E%0A%22%22%22.format(CHAIN_PATH)%0A%0A    with open(BARE_XS_FILE, %22w%22) as out:%0A        out.write(bare_xs_contents)%0A%0A    yield%0A    remove(BARE_XS_FILE)%0A%0A%0Aclass BareDepleteOperator(TransportOperator):%0A    %22%22%22Very basic class for testing the initialization.%22%22%22%0A%0A    # declare abstract methods so object can be created%0A    def __call__(self, *args, **kwargs):%0A        pass%0A%0A    def initial_condition(self):%0A        pass%0A%0A    def get_results_info(self):%0A        pass%0A%0A%0A@mock.patch.dict(environ, %7B%22OPENMC_CROSS_SECTIONS%22: BARE_XS_FILE%7D)%0Adef test_operator_init(bare_xs):%0A    %22%22%22The test will set and unset environment variable OPENMC_CROSS_SECTIONS%0A    to point towards a temporary dummy file. This file will be removed%0A    at the end of the test, and only contains a%0A    depletion_chain node.%22%22%22%0A    # force operator to read from OPENMC_CROSS_SECTIONS%0A    bare_op = BareDepleteOperator(chain_file=None)%0A    act_chain = bare_op.chain%0A    ref_chain = Chain.from_xml(CHAIN_PATH)%0A    assert len(act_chain) == len(ref_chain)%0A    for name in ref_chain.nuclide_dict:%0A        # compare openmc.deplete.Nuclide objects%0A        ref_nuc = ref_chain%5Bname%5D%0A        act_nuc = act_chain%5Bname%5D%0A        for prop in %5B%0A                'name', 'half_life', 'decay_energy', 'reactions',%0A                'decay_modes', 'yield_data', 'yield_energies',%0A                %5D:%0A            assert getattr(act_nuc, prop) == getattr(ref_nuc, prop), prop%0A

Add test for the instantiation of deplete.Operator