Add a simple unittest for the FissionYield deepcopy

This commit is contained in:
josh 2022-09-08 02:08:18 +00:00
parent 2afefba206
commit 3c7483becb

View file

@ -1,7 +1,7 @@
"""Tests for the openmc.deplete.Nuclide class."""
import xml.etree.ElementTree as ET
import copy
import numpy as np
import pytest
from openmc.deplete import nuclide
@ -335,3 +335,14 @@ def test_validate():
assert "decay mode" in record[0].message.args[0]
assert "0 reaction" in record[1].message.args[0]
assert "1.0" in record[2].message.args[0]
def test_deepcopy():
"""Test deepcopying a FissionYield object"""
nuc = nuclide.FissionYield(products=("I129", "Sm149", "Xe135"), yields=np.array((0.001, 0.0003, 0.002)))
copied_nuc = copy.deepcopy(nuc)
# Check the deepcopy equals the original
assert copied_nuc == nuc
# Mutate the original and verify the copy remains intact
nuc *= 2
assert copied_nuc != nuc