Skip to content

Commit

Permalink
Add testMethodName to test attrs in test_xsLibraries to decouple.
Browse files Browse the repository at this point in the history
This is an attempt to decouple the tests during parallel runs. We were
seeing unexpected random failures during reading the shared library.
  • Loading branch information
ntouran committed Sep 17, 2024
1 parent 88fa540 commit ba309d0
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions armi/nuclearDataIO/tests/test_xsLibraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,37 +295,33 @@ class TestXSlibraryMerging(TempFileMixin):
-----
This is just a base class, so it isn't run directly.
"""

@classmethod
def setUpClass(cls):
cls.libAA = None
cls.libAB = None
cls.libCombined = None
cls.libLumped = None

@classmethod
def tearDownClass(cls):
cls.libAA = None
cls.libAB = None
cls.libCombined = None
cls.libLumped = None
del cls.libAA
del cls.libAB
del cls.libCombined
del cls.libLumped

def setUp(self):
TempFileMixin.setUp(self)
# load a library that is in the ARMI tree. This should
# be a small library with LFPs, Actinides, structure, and coolant
for attrName, path in [
("libAA", self.getLibAAPath),
("libAB", self.getLibABPath),
("libCombined", self.getLibAA_ABPath),
("libLumped", self.getLibLumpedPath),
(f"{self._testMethodName}libAA", self.getLibAAPath),
(f"{self._testMethodName}libAB", self.getLibABPath),
(f"{self._testMethodName}libCombined", self.getLibAA_ABPath),
(f"{self._testMethodName}libLumped", self.getLibLumpedPath),
]:
if getattr(self.__class__, attrName) is None:
setattr(self.__class__, attrName, self.getReadFunc()(path()))
setattr(self, attrName, self.getReadFunc()(path()))

@property
def libAA(self):
return getattr(self, f"{self._testMethodName}libAA")

@property
def libAB(self):
return getattr(self, f"{self._testMethodName}libAB")

@property
def libCombined(self):
return getattr(self, f"{self._testMethodName}libCombined")

@property
def libLumped(self):
return getattr(self, f"{self._testMethodName}libLumped")

def getErrorType(self):
raise NotImplementedError()
Expand Down Expand Up @@ -368,16 +364,13 @@ def test_cannotMergeXSLibxWithDifferentGroupStructure(self):
def test_mergeEmptyXSLibWithOtherEssentiallyClonesTheOther(self):
emptyXSLib = xsLibraries.IsotxsLibrary()
emptyXSLib.merge(self.libAA)
self.__class__.libAA = None
self.getWriteFunc()(emptyXSLib, self.testFileName)
self.assertTrue(filecmp.cmp(self.getLibAAPath(), self.testFileName))

def test_mergeTwoXSLibFiles(self):
emptyXSLib = xsLibraries.IsotxsLibrary()
emptyXSLib.merge(self.libAA)
self.__class__.libAA = None
emptyXSLib.merge(self.libAB)
self.__class__.libAB = None
self.assertEqual(
set(self.libCombined.nuclideLabels), set(emptyXSLib.nuclideLabels)
)
Expand All @@ -388,9 +381,7 @@ def test_mergeTwoXSLibFiles(self):
def test_canRemoveIsotopes(self):
emptyXSLib = xsLibraries.IsotxsLibrary()
emptyXSLib.merge(self.libAA)
self.__class__.libAA = None
emptyXSLib.merge(self.libAB)
self.__class__.libAB = None
for nucId in [
"ZR93_7",
"ZR95_7",
Expand Down

0 comments on commit ba309d0

Please sign in to comment.