Skip to content

Commit ba309d0

Browse files
committed
Add testMethodName to test attrs in test_xsLibraries to decouple.
This is an attempt to decouple the tests during parallel runs. We were seeing unexpected random failures during reading the shared library.
1 parent 88fa540 commit ba309d0

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

Diff for: armi/nuclearDataIO/tests/test_xsLibraries.py

+21-30
Original file line numberDiff line numberDiff line change
@@ -295,37 +295,33 @@ class TestXSlibraryMerging(TempFileMixin):
295295
-----
296296
This is just a base class, so it isn't run directly.
297297
"""
298-
299-
@classmethod
300-
def setUpClass(cls):
301-
cls.libAA = None
302-
cls.libAB = None
303-
cls.libCombined = None
304-
cls.libLumped = None
305-
306-
@classmethod
307-
def tearDownClass(cls):
308-
cls.libAA = None
309-
cls.libAB = None
310-
cls.libCombined = None
311-
cls.libLumped = None
312-
del cls.libAA
313-
del cls.libAB
314-
del cls.libCombined
315-
del cls.libLumped
316-
317298
def setUp(self):
318299
TempFileMixin.setUp(self)
319300
# load a library that is in the ARMI tree. This should
320301
# be a small library with LFPs, Actinides, structure, and coolant
321302
for attrName, path in [
322-
("libAA", self.getLibAAPath),
323-
("libAB", self.getLibABPath),
324-
("libCombined", self.getLibAA_ABPath),
325-
("libLumped", self.getLibLumpedPath),
303+
(f"{self._testMethodName}libAA", self.getLibAAPath),
304+
(f"{self._testMethodName}libAB", self.getLibABPath),
305+
(f"{self._testMethodName}libCombined", self.getLibAA_ABPath),
306+
(f"{self._testMethodName}libLumped", self.getLibLumpedPath),
326307
]:
327-
if getattr(self.__class__, attrName) is None:
328-
setattr(self.__class__, attrName, self.getReadFunc()(path()))
308+
setattr(self, attrName, self.getReadFunc()(path()))
309+
310+
@property
311+
def libAA(self):
312+
return getattr(self, f"{self._testMethodName}libAA")
313+
314+
@property
315+
def libAB(self):
316+
return getattr(self, f"{self._testMethodName}libAB")
317+
318+
@property
319+
def libCombined(self):
320+
return getattr(self, f"{self._testMethodName}libCombined")
321+
322+
@property
323+
def libLumped(self):
324+
return getattr(self, f"{self._testMethodName}libLumped")
329325

330326
def getErrorType(self):
331327
raise NotImplementedError()
@@ -368,16 +364,13 @@ def test_cannotMergeXSLibxWithDifferentGroupStructure(self):
368364
def test_mergeEmptyXSLibWithOtherEssentiallyClonesTheOther(self):
369365
emptyXSLib = xsLibraries.IsotxsLibrary()
370366
emptyXSLib.merge(self.libAA)
371-
self.__class__.libAA = None
372367
self.getWriteFunc()(emptyXSLib, self.testFileName)
373368
self.assertTrue(filecmp.cmp(self.getLibAAPath(), self.testFileName))
374369

375370
def test_mergeTwoXSLibFiles(self):
376371
emptyXSLib = xsLibraries.IsotxsLibrary()
377372
emptyXSLib.merge(self.libAA)
378-
self.__class__.libAA = None
379373
emptyXSLib.merge(self.libAB)
380-
self.__class__.libAB = None
381374
self.assertEqual(
382375
set(self.libCombined.nuclideLabels), set(emptyXSLib.nuclideLabels)
383376
)
@@ -388,9 +381,7 @@ def test_mergeTwoXSLibFiles(self):
388381
def test_canRemoveIsotopes(self):
389382
emptyXSLib = xsLibraries.IsotxsLibrary()
390383
emptyXSLib.merge(self.libAA)
391-
self.__class__.libAA = None
392384
emptyXSLib.merge(self.libAB)
393-
self.__class__.libAB = None
394385
for nucId in [
395386
"ZR93_7",
396387
"ZR95_7",

0 commit comments

Comments
 (0)